NEAR and FAR pointers are from the dim past before the advent of the flat address space that is used in modern systems. They remain in the headers for compatibility purposes so that old code isn't broken but they have no meaning today.
Why this program with near pointer doesn't work?

Debojit Acharjee
455
Reputation points
Why this program with near pointer doesn't work on VS Code?
#include <stdio.h>
int main()
{
// declaring a near pointer
int near* ptr;
// size of the near pointer
printf("Size of Near Pointer: %d bytes", sizeof(ptr));
return 0;
}
Output:
Accepted answer
2 additional answers
Sort by: Most helpful
-
Castorix31 88,381 Reputation points
2023-07-28T15:19:24.1533333+00:00 In VS 2022, for "near" :
#include <windows.h> #include <stdio.h>
-
Bruce (SqlWork.com) 74,536 Reputation points
2023-07-28T15:50:10.8033333+00:00 Because you are using a compiler (like most) that does not support these keywords.
near and far are custom keywords for an old windows intel c compiler and are used for accessing segmented memory. Few C/C++ compilers support these keywords any more as this hardware is fairly obsolete.
you really should not use these unsupported keywords. The windows.h include define them as blank (so they basically are removed), so if you add windows.h your code will compile, but really you should not use them.