且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么 Windows API 中的所有内容都是 typedef 的?

更新时间:2023-02-10 07:51:45

PCWSTR 和 LPCWSTR 之所以同时存在,是因为在古代是有区别的.LPCWSTR 曾经是 const WCHAR FAR *.

More specifically, why is the same thing typedef'd with multiple different names in many cases, and why typedef pointer types (obscuring logic at times)?

For example:

typedef const WCHAR *LPCWSTR, *PCWSTR;

What is the point of that?

The reason there is both PCWSTR and LPCWSTR is that in ancient times there was a difference. LPCWSTR used to be const WCHAR FAR *.