I wonder if anyone has a full list of C/C++ data types and their conversions to ASM data types. I know most of the common ones but there appears to be an ever increasing number of the data types.

I am playing with a tool to autoconvert the sum total of information in the complete win2k set of .H files. What I have done at the moment is combine all of the .H files into one 33 meg file so i can scan it in one run.

I need a good list of the types to try and do the data type conversions on the fly. ANy help would be appreciated.

Regards,

hutch@movsd.com
Posted on 2002-11-08 06:33:45 by hutch--
The basic types are:

bool
char
wchar_t (wide char character)
int
short (int)
long (int)
float
double
long double

The C++ specs do not define exact sizes for each type, because of portability. This is what C++ guarantees about it's fundamental types:

sizeof(char) === 1 by definition
sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)
1 <= sizeof(bool) <= sizeof(long)
sizeof(char) <= sizeof(wchar_t) <= sizeof(long)
sizeof(float) <= sizeof(double) <= sizeof(long double)
sizeof(N) === sizeof(signed N) === sizeof(unsigned N)

Furthermore, a char is *at least* 8-bits, a short is at least 16 bits and a long is at least 32 bits.

For x86 the sizes are:

bool = 1 byte in VC++
char = 1 byte
wchar_t = 2 bytes
int = 4 bytes (DWORD/SDWORD)
short = 2 bytes (WORD/SWORD)
long = 4 bytes (DWORD/SDWORD)
float = 4 bytes (REAL4)
double = 8 bytes (REAL8)
long double = 10 bytes (REAL10)

The win32api often uses it's own typedefs for all declarations, like BYTE, LONG, INT etc. As far as I know they conform to the C type sizes, except for bool. A BOOL (uppercase) is 4 bytes in the API, but a C bool (well, in VC++) is 1 byte.

Thomas

edit: Of course there's also void, it's not a real type but you can have void pointers..
Posted on 2002-11-08 07:04:05 by Thomas
hutch--,
Are you using a C parser to scan through the .h files?
If its open source can i have it please?
Posted on 2002-11-08 07:05:00 by clippy
The C++ specs do not define exact sizes for each type, because of portability.

BTW: doesn't this sound like a paradox? :) It would be much more portable to use U32/S32, U16/S16, etc.. anyway.
Posted on 2002-11-08 07:52:10 by Maverick
It depends of the point of view...

C define ranges only (limits.h), and express all its other types in char (sizeof() returns a number expressed in "char"s, not "bytes") which maybe 8 bit long or not...
Posted on 2002-11-08 11:05:10 by JCP
This is the MS list:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/windows_data_types.asp
Now, if you are looking for a list of types like CONST LOGPALETTE or LPTEXTMETRIC, perhaps the only way to go is improvisation, like registering everything that starts with 'LP' as a long pointer...

[edit: Talk about confusion: TBYTE is 1 or 2 bytes for windows. Wasn't that a Tenbyte (80 bits) ?
Posted on 2002-11-08 13:51:12 by micmic
micmic,
types like LPTEXTMETRIC are made with macros (#define) statements in C++, to give a more meaningful name to structures or data types.
Which is why you need a 'C' parser to get all the info from the header files.
Posted on 2002-11-09 05:56:35 by clippy
the compiler guys say, that the C compiler knows better, how to realize the data types, like -32768...32767 in the physically hardware.

Assembly guys say, this is bullsh*t :)

This is like the MS WORD paper clip, that recommends you always and permanently the things you did not want to and you never know
how to switch off this features :)
Posted on 2002-11-11 04:27:53 by beaster
We all know about C/C++ portability but the data sizes must be applied to a platform somewhere and this is what I am after. 64 bit MIPS C/C++ is obviously not much use in win32.

Simple stuff like,

HANDLE equ DWORD
HINSTANCE equ DWORD

What I am looking for is the rest, I know most of the simple stuff in win32 but the proliferation is hard to keep up with.

Regards,

hutch@movsd.com
Posted on 2002-11-11 07:04:32 by hutch--
wtf?

33 Megs of type casts?? And you say there is more still??

That is bloar indeed... it is even hard t imagine, 33 Megs of plain text... I use to think the mega byte that window.inc was already a little too much... anyway, IMHO, most of them will be a 32 bit value. No matter if it is used as pointer or variable. We still use bytes, mostly to ASCII, because would be hard to think four letters at onde.. ;) ...

I think it could be more usefull to US, win32asm programmers, just a few simple lists of type casts, wich would be divided into sections (or files): byte, word, dword. END... other would be multiple (as they are already ;) and inside each one would be the name of the casts separated by one simple byte (13h or anything one byte long) so we could rapidly verify what is a certain type, when we are reading through C/C++ source ( most commom ones ).

Ps: if you compress this 33MB file, how much will it turn to? 8-)
Posted on 2002-11-13 12:19:03 by wicr0s0ft