Macros
Some macros can be used to describe the wchar_t
type.
Including <wchar.h>
makes the macro WCHAR_MAX
available.
At least
gcc also defines some
__WCHAR*
macros:
#include <stdio.h>
//
// <wchar.h> seems to be needed for WCHAR_MAX.
//
#include <wchar.h>
//
// See
// https://renenyffenegger.ch/notes/development/languages/C-C-plus-plus/CPP/preprocessor/macros/stringify
// for QuoteIdent and QuoteMacro
//
#define QuoteIdent(ident) #ident
#define QuoteMacro(macro) QuoteIdent(macro)
#define printMacroDefinition(macro) printf("%-22s %s\n", #macro ":", QuoteMacro(macro));
int main() {
printMacroDefinition(WCHAR_MAX )
printMacroDefinition(__SIZEOF_WCHAR_T__)
printMacroDefinition(__WCHAR_MAX__ )
printMacroDefinition(__WCHAR_MIN__ )
printMacroDefinition(__WCHAR_UNSIGNED__)
printMacroDefinition(__WCHAR_TYPE__ )
}
This program might print something like
WCHAR_MAX: 0x7fffffff
__SIZEOF_WCHAR_T__: 4
__WCHAR_MAX__: 0x7fffffff
__WCHAR_MIN__: (-0x7fffffff - 1)
__WCHAR_UNSIGNED__: __WCHAR_UNSIGNED__
__WCHAR_TYPE__: int