char/short/int/long/void* and WPARAM/LPARAM/HANDLE on win64

Started by
3 comments, last by Rattrap 10 years ago

This is basic but really idont know

I assume on win32

char is 8bit, short is 16 int is 32 long is 32 too,

HANDLE (HWND, HDC) is same as void* (32 bit)

LPARAM/WPARAM i really donk know - ?

(some other win32 typew worth knowing the size?)

Is thislike that? How it looks on win64? (I mean x64 winapi)

Advertisement

You can write a tiny program that uses sizeof() to tell you how big any of those things are.

You can write a tiny program that uses sizeof() to tell you how big any of those things are.

I got no x64 windows (x64 proc but x32 win xp)


HWND a;
HDC b;
WPARAM c;
LPARAM d;
static_assert(sizeof(a) == 8, "Bad");
static_assert(sizeof(b) == 8, "Bad");
static_assert(sizeof(c) == 8, "Bad");
static_assert(sizeof(d) == 8, "Bad");

short, etc have the same size on all Windows platforms.

There are types like ULONG_PTR, that are different on various platforms.

Handles have different sizes too.

Maybe you would have a possibility to test your app on X64 platform.

It would have bugs, because of the difference.

MSDN - Window Data Types

These are how Microsoft defines types in the Windows headers. They are well defined in the scope of Windows. Most of the types wont change in size, but ones that are intended to store pointers can change in size based on the target platform.

Note that target platform is not the same as target processor. You can run a 32-bit application in a 64-bit environment. Since it was compiled for a 32-bit target, values like LPARAM will be 32-bits. If it is targeted for a 64-bit platform, types like LPARAM will expand to a 64-bit value. Look at the link I provided above, it should tell you which ones do this.

"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]

This topic is closed to new replies.

Advertisement