What does Far mean in c?

前端 未结 3 606
一向
一向 2021-01-04 03:16
const struct sockaddr FAR* name,
相关标签:
3条回答
  • 2021-01-04 04:13

    It's an old extension from the era of segmented memory architectures. It basically means "this is a pointer that needs to be able to point at any address, not just things in the same segment as the code using it".

    See more or on the wikipedia page.

    0 讨论(0)
  • 2021-01-04 04:19

    far doesn't mean anything in C. Check out the C99 standard [PDF] and see if you can find mention of far pointers. Far pointers were an extension added to compilers targeting the 8086/80286 architectures to provide support for the segmented memory model.

    0 讨论(0)
  • 2021-01-04 04:20

    If does nothing unless you happen to be using a 16 bit x86 compiler.

    If you look in the Win32 header WinDef.h (in Visual Studio, simply right-click the word FAR in the source and select "Go to Definition", you will see that it is a macro defined as far, which in turn is also a macro defined as nothing at all!

    It is only there to allow the compilation of legacy Win16 source as Win32. In 16 bit x86 compilers, far was a compiler extension keyword to support seg::offset pointers which resolve to a 20bit address (16 bit x86 only had a 1Mb address space!). They are distinct from 16 bit near pointers which comprised only the ::offset from the current segment.

    0 讨论(0)
提交回复
热议问题