Data Types

Hi all,

I'm on Mac OS X using C++ to load a bitmap image for texturing in OpenGL, however the few tutorials i have, use WORD and DWORD data types in the BITMAPFILEHEADER and BITMAPINFOHEADER structs - These are Windows32 data types are they not.

I have read that it the length of the data types is dependant on the OS and/or the compiler.

Can someone please shed some light on what would be appropriate replacement types for WORD/DWORD for use in my structs.

Thanks.
1
2
3
4
5
6
7
8
9
10
11
12
#include <cstdint>

typedef uint8_t  CHAR;
typedef uint16_t WORD;
typedef uint32_t DWORD;

typedef int8_t  BYTE;
typedef int16_t SHORT;
typedef int32_t LONG;

typedef LONG INT;
typedef INT BOOL;

That should be more than enough...

Hope this helps.
Thanks for the reply Duoas.

I understand what putting "unsigned" and "signed" in front of a type does, but when you precede INT with LONG and BOOL with INT, what are those effects?

Also, what exactly is the construct "uint8_t, uint16_t ... " you are using above?

Thanks for your help.
typedef xxx yyy; means now you can use the new data type yyy as if it was xxx
so
1
2
typedef int ABCD;
ABCD x;//this would be as int x; 


http://www.cplusplus.com/doc/tutorial/other_data_types.html
typedef LONG INT; means "whenever I'm using INT, I actually mean LONG". The same applies to the line below.

int#_t are types exactly # bits long (i.e. int8_t is 8 bits long, int16_t is 16 bits long, etc.). uint#_t are the same, but unsigned.
Hey thanks both of you for your help.

Much appreciated.
Topic archived. No new replies allowed.