I am new to programming in the Windows environment. The language I use is C. More specifically, I try to manipulate COM-ports on Windows manually (without special libraries, only WinAPI functions).
My question concerns the presence lots of typedef's in windows.h. What purpose do they serve?
Is it OK to mix bool, BOOL, unsigned int and WORD, for example, in one source file (from the points of view either coding style or effectiveness), or I need some kind of standardization (use BOOL instead of bool everywhere and so on)?
The typical example of function with different parameter types in my code is this:
bool ConfigureDCB( HANDLE hp_ComPort,
bool bUseCurrentSettings,
DWORD dwBaudRate,
BOOL bParityCheck,
BYTE byteSize,
BYTE parityMode,
BYTE stopBits )
There are both BOOL and bool types among the function parameters. The first one is used exactly as prescribed in header file (its value is set directly to a BOOL member of structure), and the second one (and function return type as well) is used only as part of program logic:
if(!bUseCurrentSettings)
{
...
}
bool ConfigureDCB( HANDLE hp_ComPort
is this question.bool
in C and it seems that some headers like stdbool.h or others wherebool
is defined are included indirectly by the compiler, so then I do not receive any errors or warnings when I usebool
. There is a parameterstd=c99
in my command line either.