http://msdn.microsoft.com/en-us/library/aa505945.aspx

im curious as to why microsoft has typedef'ed simple "data types"? what's the point of this and why should i use them in my programs?

Recommended Answers

All 2 Replies

For clarity. A lot of the typedefs help explain usage. DWORD tells you more than unsigned long as to what the intended usage is.

If you program to an interface it is important to keep with the requirements of that interface. typedefs can help hide information. For instance, suppose that DWORD is typedef int DWORD and you programmed functions knowing that

int foo (int param1, int param2);
// instead of DWORD foo (DWORD param1, DWORD param2)

Suppose you wrote an entire library that way. Now suppose that in all implementations DWORD is now typedef void * DWORD . If you programmed to the interface you would need to change nothing and your code would still work, but as it stands you now need to re-write the entire interface to accomodate this change.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.