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:
Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other
A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
Answer accepted by question author
2 additional answers
Sort by: Most helpful
-
Castorix31 91,511 Reputation points2023-07-28T15:19:24.1533333+00:00 In VS 2022, for "near" :
#include <windows.h> #include <stdio.h> -
Bruce (SqlWork.com) 82,146 Reputation points Volunteer Moderator
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.