-
Notifications
You must be signed in to change notification settings - Fork 6
Data Type Cheat Sheet
You can find the full list of Windows data types in this
page.
So how to do we know corresponding Go type for C type X?
There are typedef Y X;
lines under each type definitions.
What you need to do is just following the type definition
until you find the basic data types like int
, short
, etc.
For example, if you wish to know what HMENU
is, first find HMENU
in the page.
Here it is:
HMENU
A handle to a menu.
This type is declared in WinDef.h as follows:
typedef HANDLE HMENU;
So HMENU
is same as HANDLE
. But what is HANDLE
? Again find in the page, this time for HANDLE
:
HANDLE
...
typedef PVOID HANDLE;
Oh okay, find PVOID
again:
PVOID
...
typedef void *PVOID;
Finally we got void*
. So we can pass uintptr
data as argument for API that accepts HMENU
. Easy, but can be boring. So here I listed common C data types along with its corresponding Go type.
C | Go |
---|---|
int |
int32 |
unsigned int |
uint32 |
short |
int16 |
unsigned short |
uint16 |
long |
int32 |
unsigned long |
uint32 |
unsigned long long |
uint64 |
C | Go |
---|---|
INT |
int32 |
UINT |
uint32 |
BOOL |
int32 |
BYTE |
byte |
CHAR |
int8 |
DWORD |
uint32 |
HANDLE |
uintptr |
H* (HBRUHSH , ...) |
uintptr |
HRESULT |
int32 |
(WIP)