Thread: Windows API alternative data types

  1. #1
    Registered User
    Join Date
    Oct 2003

    Question Windows API alternative data types

    Why does Windows API use UINT instead of unsigned int? And BOOL instead of bool?

    And in openGL...
    Why GLfloat instead of float? and GLint instead of int? Why are all these things different?

  2. #2
    Grammar Police HybridM's Avatar
    Join Date
    Jan 2003
    They're just typedefs, they're exactly the same.

    Win32 does it because it apparently fits in with their style of notation (called hungarian notation). However things like UINT double as a handy abbreviation.

    As for GL I'm not sure but I'm guessing it's just a mechanism that helps any maintainer identify that this variable will be used by OpenGL.
    Thor's self help tip:
    Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.

    OS: Windows XP
    Compiler: MSVC

  3. #3
    Registered User
    Join Date
    Jul 2003
    for example, an int may be of different sizes depending on what platform you are using.
    Therefore cross platform libs such as opengl need to define their own data types so you can count on that the size of your data type is the same on all platforms.

  4. #4
    Registered User
    Join Date
    Oct 2003
    Thanks! So for Win32, since I can't port it - I can just use things like int, char and whatever?

    but in openGL its best to use GLfloat ect, so I can port it easily


  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > I can just use things like int, char and whatever?
    Use the types specified in the win32 API.
    Some of the underlying types actually changed from win16 to win32, but the typedef'ed name didn't change (to maintain compatibility with older code). If you use the current underlying types, you'll suffer when win64 comes along.

    If you don't like the names, you could always do
    typedef BOOL mywin32_bool;

    But think carefully before doing this. You could end up with code which looks all wierd and unmaintainable to any other win32 programmer.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Tha 1 Sick RAT
    Join Date
    Dec 2003
    Actually this is a problem I forsee having with Windows programming. DOes anyone know where I can get hol of a list detaling the relations of windows API alternative data types to normal/original primitive datatypes?
    Thanx y'all.
    A hundred Elephants can knock down the walls of a fortress... One diseased rat can kill everyone inside

  7. #7
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    You have already that information, its all in the windows.h header heirarchy. Just go peruse it.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :-

  8. #8
    Registered User
    Join Date
    Jan 2004
    If you don't want to mess in your headers (however it's more useful to learn it):

    And btw: BOOL != bool (BOOL is in fact an unsigned integer i tought)

  9. #9
    Registered User
    Join Date
    Jun 2003
    BOOL is bool

    If you Right-Click on the variable (BOOL, UINT) and scroll down the menu to "Go To Definition" and click on that, it will show you the actual definition and answer many of your questions.

    And my bad, BOOL is actually an integer (signed)....
    Last edited by Epo; 01-02-2004 at 07:26 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 06-14-2005, 05:45 AM
  2. Errors
    By Rhidian in forum C Programming
    Replies: 10
    Last Post: 04-04-2005, 12:22 PM
  3. Programming Windows API in C++
    By JoshR in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2005, 05:40 AM
  4. Data types in Unicode
    By Garfield in forum Windows Programming
    Replies: 12
    Last Post: 10-28-2001, 10:48 AM
  5. Need help with simple data types
    By partnole in forum C++ Programming
    Replies: 1
    Last Post: 10-03-2001, 08:36 AM