Windows Typedef's

This is a discussion on Windows Typedef's within the Windows Programming forums, part of the Platform Specific Boards category; Why exactly does windows use so many typedefs? Are there any guarantees about these typedefs? IE same size from implementation ...

  1. #1
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507

    Windows Typedef's

    Why exactly does windows use so many typedefs? Are there any guarantees about these typedefs? IE same size from implementation to implementation? Otherwise some of them seem somewhat redundant, IE CHAR, PCHAR, BYTE, on and on.

    I have tried to stick with these typedefs when writing windows apps but I suppose I've never stopped to think and ask, hey why am I doing it this way? Do I gain anything by using a DWORD over unsigned long, etc etc...

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,243
    Quote Originally Posted by valaris View Post
    Why exactly does windows use so many typedefs? Are there any guarantees about these typedefs? IE same size from implementation to implementation? Otherwise some of them seem somewhat redundant, IE CHAR, PCHAR, BYTE, on and on.

    I have tried to stick with these typedefs when writing windows apps but I suppose I've never stopped to think and ask, hey why am I doing it this way? Do I gain anything by using a DWORD over unsigned long, etc etc...
    What you gain is consistency with all the other Windows-targetted code out there. You have to realize that most of this stuff came from the pre-32-bit days of Windows 3.0. Programmers were still used to reading/writing assembly code, and a 32-bit quantity was called a "DWORD."

    As far as the various P* symbols, that's Hungarian notation, and yes, a lot of us hate it as well. However, when writing code for Windows I tend to stick to it as least as far as types are concerned, just so other people will understand what I've written.

    Also, Windows programming has a long tradition of copy-paste, and since Microsoft's examples use these types, they end up in working code as well.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Windows 98/2000 programming in Windows XP
    By Bill83 in forum Windows Programming
    Replies: 3
    Last Post: 07-22-2005, 02:16 PM
  2. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 05:48 PM
  3. dual boot Win XP, win 2000
    By Micko in forum Tech Board
    Replies: 6
    Last Post: 05-30-2005, 02:55 PM
  4. SDL and Windows
    By nickname_changed in forum Windows Programming
    Replies: 14
    Last Post: 10-24-2003, 12:19 AM
  5. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21