Check sizeof a type
check_type_size(<type> <variable> [BUILTIN_TYPES_ONLY] [LANGUAGE <language>])
Check if the type exists and determine its size. Results are reported in the following variables:
Holds a true or false value indicating whether the type exists.
Holds one of the following values:
Type has non-zero size
Type has architecture-dependent size. This may occur when
CMAKE_OSX_ARCHITECTUREShas multiple architectures. In this case
<variable>_CODEcontains C preprocessor tests mapping from each architecture macro to the corresponding type size. The list of architecture macros is stored in
<variable>_KEYS, and the value for each key is stored in
- "" (empty string)
Type does not exist.
Holds C preprocessor code to define the macro
<variable>to the size of the type, or to leave the macro undefined if the type does not exist.
The options are:
Support only compiler-builtin types. If not given, the macro checks for headers
<stddef.h>, and saves results in
HAVE_STDDEF_H. The type size check automatically includes the available headers, thus supporting checks of types defined in the headers.
<language>compiler to perform the check. Acceptable values are
Despite the name of the macro you may use it to check the size of more complex expressions, too. To check e.g. for the size of a struct member you can do something like this:
check_type_size("((struct something*)0)->member" SIZEOF_MEMBER)
The following variables may be set before calling this macro to modify the way the check is run:
string of compile command line flags.
list of macros to define (-DFOO=bar).
list of include directories.
New in version 3.14: list of options to pass to link command.
list of libraries to link.
New in version 3.1: execute quietly without messages.
list of extra headers to include.