why does microsoft make the C++ header files impossible to read

Viewed 26

General question as everytime I go and read any header file from the standard file I am met with the most unreadable non-sensical/logical names possible that almost seem terrible on purpose from how bad they are. Is there any particular reason why Microsoft loves to PROCESS_CREATION_MITIGATION_AUDIT_POLICY2_USER_CET_SET_CONTEXT_IP_VALIDATION_ALWAYS_OFF and somehow make pointers long LP, far and __TCNIS* __WDICO_Io_ = __SomethingWithABadName

1 Answers

Long names are the C version of namespaces and the Windows headers have to be compatible with C. You picked an unusually long name there as your example, it is not usually that bad.

LP and FAR is because of 16-bit history.

On 16-bit architectures (16-bit Windows) there are 2 types of pointers, P for "pointer" and LP stands for "long pointer". Long pointers (also called far pointers) were needed to address memory ranges outside of the current segment. The LP prefix has been preserved to make it easier to port 16-bit code to 32-bit Windows. Today there is no distinction, and these pointer types are all equivalent. Avoid using these prefixes; or if you must use one, then use P.

You can see the remnants of 16-bit memory models in the macros NEAR and FAR defined by windows.h. They don’t mean anything any more, but they remain for source code backward compatibility.

Win32 was 99% source compatible with Win16 and while it helped developers back then we are now stuck with this stuff forever.

Names starting with __ are reserved and you should ideally not interact with them...

Related