Defines and typedefs such as BOOL, CONST, UINT and DWORD are used pretty much everywhere in the codebase.
Most of these defines where introduced a long time ago (BOOL was added before bool was thrown into C++) and now, most of them are meaningless.
Nowadays, every decent compiler should support C++'s fundamental types without any problem.
Of course, DirectX types and some other funky types (HWND, HHOOK and so on) can't be replaced but there's no excuse for more common types I've pointed out earlier.
Pros
Less error-prone (every Microsoft specific type names are upper case)
Makes high-level parts of the engine less dependent on MSVC / Windows API
Improves compile/runtime speed and makes debugging tasks easier (BOOL is a int typedef whereas bool is a true type)
Syntax highlighting / code readability is slightly improved; GitHub syntax highlighter (and probably many others) don't know about BOOL, HANDLE or DWORD but it does its job perfectly well on the standard types.
#
Cons
Nothing. Really, I can't think of any drawbacks.
What to do?
There's nothing hard. We just need to search for these types and replace them by their standard
equivalent.
If you really have to use a non-standard type in a piece of code, it should be better to keep this code 'away (i.e. not in a header nor in the middle of a high-level source file)
To make things easier, here's a table with what should be considered for replacement and their equivalents.
1 - Representation of an integer type for pointer precision
INT_PTR / LONG_PTR are mapped to a 32-bit signed integer on 32-bits systems and to a 64-bit signed integer on 64-bits systems.
DWORD_PTR / UINT_PTR are mapped to a 32-bit unsigned integer on 32-bits systems and to a 64-bit unsigned integer on 64-bits systems.
It's clear that the easiest way to do that would be to use cstdint along with the standard types. Feel free to share anything, any ideas about all this.
Defines and typedefs such as
BOOL
,CONST
,UINT
andDWORD
are used pretty much everywhere in the codebase. Most of these defines where introduced a long time ago (BOOL
was added beforebool
was thrown into C++) and now, most of them are meaningless. Nowadays, every decent compiler should support C++'s fundamental types without any problem. Of course, DirectX types and some other funky types (HWND
,HHOOK
and so on) can't be replaced but there's no excuse for more common types I've pointed out earlier.Pros
BOOL
is aint
typedef whereasbool
is a true type)BOOL
,HANDLE
orDWORD
but it does its job perfectly well on the standard types.#
Cons
What to do?
There's nothing hard. We just need to search for these types and replace them by their standard equivalent. If you really have to use a non-standard type in a piece of code, it should be better to keep this code 'away (i.e. not in a header nor in the middle of a high-level source file) To make things easier, here's a table with what should be considered for replacement and their equivalents.
INT8
signed char
int8_t
PINT8
signed char *
int8_t *
BYTE
/UCHAR
/UINT8
unsigned char
uint8_t
LPBYTE
/PBYTE
unsigned char *
uint8_t *
INT16
/SHORT
signed short
int16_t
PINT16
/PSHORT
signed short *
int16_t *
USHORT
/WORD
/UINT16
unsigned short
uint16_t
LPWORD
/PWORD
unsigned short *
uint16_t *
INT
/INT32
/LONG
/LONG32
signed int
int32_t
LPINT
/PINT
/LPLONG
/PLONG
/PINT32
/PLONG32
/PLONG
signed int *
int32_t *
DWORD
/DWORD32
/UINT
/UINT32
/ULONG32
/ULONG
unsigned int
uint32_t
LPDWORD
/PDWORD
/PDWORD32
unsigned int *
uint32_t *
INT64
/LONGLONG
/LONG64
signed long long
int64_t
PINT64
/PLONG64
/PLONGLONG
signed long long *
int64_t *
DWORDLONG
/DWORD64
/QWORD
/UINT64
/ULONGLONG
/ULONG64
unsigned long long
uint64_t
INT_PTR
/LONG_PTR
intptr_t
DWORD_PTR
/UINT_PTR
uintptr_t
BOOL
/BOOLEAN
bool
LPBOOL
/PBOOL
/PBOOLEAN
bool *
CCHAR
/CHAR
char
LPSTR
/PCHAR
char *
LPCSTR
/PCSTR
const char *
CONST
const
FLOAT
float
PFLOAT
float *
VOID
void
LPCVOID
const void *
WCHAR
wchar_t
LPWSTR
/PWSTR
/PWCHAR
wchar_t *
LPCWSTR
/PCWSTR
const wchar_t *
1 - Representation of an integer type for pointer precision
It's clear that the easiest way to do that would be to use cstdint along with the standard types. Feel free to share anything, any ideas about all this.