I wanted to use the a far pointer in my program the declaration was like this char far* ptr; but when I compile the program the compiler gives error message that far undeclared, can any one help me in this regard how to use near, far, and huge pointers in Dev C++, secondly If I want to assign a value to a pointer such as ptr = 0xb800 the compiler again gives error so is this possible to initialize a pointer as shown above in Dev C++ envoirnment.

12 Years
Discussion Span
Last Post by Ancient Dragon

The 'far' keywork only makes sense under DOS, and is useless with minGW.

if you are trying to port code from djgpp, you may neutralize it. For example, add '-Dfar' to the compiler commandline (Project/project options/ parameters).

The win32 api defines the far macro (and replaces it by nothing) in the file windef.h. If you want to use it in your code properly, you can #include the win32 api header, windows.h.

Forcing the value of a pointer is a bit dirty, Why are you trying to do this ?

#include <windows.h>"

/*C style*/
void * far myPtr=(void*)0xdeadbeef;

/*C++ style*/
void * far myPtr=reinterpret_cast<void*>(0xdeadbeef);

Forcing the value of a pointer is a bit dirty

md: In MS-Windows and *nix it will most probably crash the program because the operating systems do not allow programs to access memory addresses that way. Gone are the days of MS-DOS when a program could just write to random memory addresses.

Some 16-bit MS-DOS compilers (e.g. Turbo C) are still available for free.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.