1

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.

mnabil
  • 695
  • 1
  • 5
  • 19
  • 1
    Which platform are you compiling for? `far` pointers were used back in the olden days, but are not relevant on modern platforms. See https://stackoverflow.com/questions/1749904/what-is-the-difference-between-far-pointers-and-near-pointers – cdarke Nov 05 '18 at 16:36
  • I'm compiling for Win 7. Thanks @cdarke for the link; I understood that there is no need now for far or near pointer; am I correct? – mnabil Nov 05 '18 at 16:39
  • There might be a need if you are crossing--compiling for a 16-bit platform, but for Win 7, no. Where did you get the idea from that you needed a far pointer? It could be that you are using an old source that won't work any more. – cdarke Nov 05 '18 at 16:45
  • Normally the Windows header files define `far` as expanding to nothing (`#define far`). Did you include `windows.h` in your source code? If you cannot (or don't want) to include `windows.h`, you can just add `#define far` in your file or whatever header. – Jabberwocky Nov 05 '18 at 16:56
  • Yes, I'm compiling for old src code; It works by defining far to nothing. Please make it in a different answer so I can accept it. – mnabil Nov 05 '18 at 17:05

2 Answers2

1

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.

Petar Velev
  • 2,305
  • 12
  • 24
1

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.

Jabberwocky
  • 48,281
  • 17
  • 65
  • 115