开发者

What does Far mean in c?

开发者 https://www.devze.com 2023-01-22 05:44 出处:网络
const struct sockaddr FAR* 开发者_运维知识库name, 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 ad
const struct sockaddr FAR* 开发者_运维知识库name,


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.


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.


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

精彩评论

暂无评论...
验证码 换一张
取 消