"VOID" as opposed to void

This is a discussion on "VOID" as opposed to void within the Windows Programming forums, part of the Platform Specific Boards category; I was looking at some sample code for mouse input... And I noticed that the return type was "VOID" on ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    417

    "VOID" as opposed to void

    I was looking at some sample code for mouse input...

    And I noticed that the return type was "VOID" on a few functions.

    And this:

    printf(typeid(VOID).name());

    results with "void" on the screen... so is VOID a typedef for void? If so, what is the point of it?

  2. #2
    Open to suggestions Brighteyes's Avatar
    Join Date
    Mar 2003
    Posts
    204
    >If so, what is the point of it?
    Microsoft thought it up...that should tell you enough. I've always been fond of this little gem from windows.h:
    Code:
    typedef WORD ATOM;
    p.s. What the alphabet would look like without q and r.

  3. #3
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,262
    The Platform SDK is supposed to be compatible with multiple platforms, so the core types (void, int, long, etc.) are defined as they are used within the SDK, so if, for example, you compiled it on a 64-bit platform (Where int is 8 bytes long not 4), the SDK type INT should still equate to the 4 byte version it uses.

    That's the theory, anyway...

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    On 64-bit, int is still 4 bytes, at least in gcc.

    VOID is also the product of the windows naming convention which says that all type names must be all-caps.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Registered User
    Join Date
    Dec 2002
    Posts
    162
    If you wanna four byte int why not just write "long int"?
    We haven't inherited Earth from our parents; instead we have borrowed her from our children - old Indian saying.

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >If you wanna four byte int why not just write "long int"?
    Probably because a long int isn't guaranteed to be four bytes. The only guaranteed size in C/C++ is char, which is always 1. The other sizes are defined as follows:

    char <= short <= int <= long

    Even char being 1 isn't well defined, the sizeof(char) is always 1, but the actual number of bits that a char represents can be anything greater than 8.
    My best code is written with the delete key.

  7. #7
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    char is one byte, but byte is machine-dependent.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  8. #8
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    Originally posted by CornedBee
    char is one byte, but byte is machine-dependent.
    And a char on a unicode system would be?

  9. #9
    Cat
    Guest
    char is still one byte on Windows, even if you compile it and run it on NT or XP (native Unicode). TCHAR would be 2 bytes, though, if you compile under Unicode.

  10. #10
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >And a char on a unicode system would be?
    One byte. However, one byte often doesn't handle Unicode values, which is why standard C/C++ has wchar_t.
    My best code is written with the delete key.

  11. #11
    Registered User
    Join Date
    Feb 2003
    Posts
    76
    VOID is not really a typedef, it's a macro, because it would be illegal in some compilers to do this:

    Code:
    typedef void VOID;
    Personally, though, I don't use VOID, just void; however I use PVOID and LPVOID.

  12. #12
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    I'm talking about how much room a unicode character occupies. I think we are talking about different things.

  13. #13
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    UTF-8 occupies anywhere from 1 to 5 bytes.
    UTF-16 always occupies 2 bytes.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  14. #14
    Registered User
    Join Date
    Dec 2002
    Posts
    162
    Originally posted by poccil
    Personally, though, I don't use VOID, just void; however I use PVOID and LPVOID.
    What is LPVOID?

  15. #15
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Originally posted by Aidman
    What is LPVOID?
    From Wtypes.h:
    Code:
    typedef void *LPVOID;
    (PVOID is the same).

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. How to better manage large .cpp files
    By 39ster in forum C++ Programming
    Replies: 6
    Last Post: 08-25-2008, 08:24 AM
  4. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 04:42 PM
  5. Error, not sure what it means.
    By RealityFusion in forum C++ Programming
    Replies: 1
    Last Post: 09-25-2005, 01:17 PM

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