Why typedef char CHAR

Guys taking a quick look at Winnt.h I found that there are many typedefs, and one of them is CHAR for char for example. What for? What was the purpose of these typdefs? Why not use something that already exists (char, int, etc.)?
Thanks.

+2


a source to share


2 answers


The WIN32 API must also be agnostic. When the compiler is tuned for different word sizes, the types can change as well.

For example, on 16-bit platforms:

typedef WORD unsigned int;
typedef DWORD unsigned long;

      



On 32-bit platforms:

typedef WORD unsigned short;
typedef DWORD unsigned int;

      

In this example, your mileage may vary.

+4


a source


The win32 API must be agnostic. Typedefs are tied to the actual sizes of the elements on the x86 processor. Thus, CHAR is char, an unsigned long DWORD .... All of this is so that languages ​​other than C and C ++ can "connect" to APIs even with different memory models.



+9


a source







All Articles