far pointer declaration in Visual Studio

2020-04-27 07:41发布

I have a far pointer declaration in this way:

char far *p;

But visual studio 2008 give me

error C2146: missing ';' before identifier 'p'

Any help is appreciated.

2条回答
做自己的国王
2楼-- · 2020-04-27 08:16

far was a keyword in the 16 bit Microsoft compiler (and possibly other old compilers). Nowadays in the 32/64 bit world this keyword has become obsolete and useless.

Normally the Windows header files define far as expanding to nothing.

If you include windows.h your code should compile.

If you cannot or don't want to include windows.h, you can just add #define far in your file or whatever appropriate header file of your project.

Or best remove far manually from your source files.

查看更多
成全新的幸福
3楼-- · 2020-04-27 08:29

This is not standard C syntax. This was an added feature for < 32-bit compilers.

They are not needed and thus not supported on the modern compilers.

The implementation of this pointers may vary from compiler to a compiler.
The standard Microsoft compiler should not support this feature and should give you an error as it does. There might be a specific compiler for a specific hardware which extends the language to give you this feature.

查看更多
登录 后发表回答