Why does windows have its own data types?

From my book:

"Windows Data Types

Windows defines a significant number of data types that are used to specify function parameter types and return types in the Windows API. These Windows-specific types also propagate through to functions that are defined in MFC. Each of these Windows types will map to some C++ type, but because the mapping between Windows types and C++ types can change over time, you should always use the Windows type where this applies. For example, in the past the Windows type WORD has been defined in one version of Windows as type unsigned short and in another Windows version as type unsigned int. On 16-bit machines these types are equivalent, but on 32-bit machines they are decidedly different so anyone using the C++ type rather than the Windows type could run into problems."

Can anyone explain the "problems?" I dont exactly understand what problem you would end up in.

Every operating system has its own datatypes.

The problems they're talking about are some integral types varying with machine architecture or not having a clear definition. For example, an int is a machine word, and short/long sizes not being specified.

In Windows, WORD and DWORD have specific sizes (16 and 32 bits respectively).

This was solved in C99 with the types defined in stdint.h. But Window predates that.
Oh ok thanks
But wouldn't you still have he same problem? Because the definition would still vary? If you used the c++ wouldn't you not run into run the problem because the type will be the same?

Kinda of confused.
Last edited on
Can anyone please help!
Topic archived. No new replies allowed.