Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Preprocessor and macros

Export macro values into the python module

Some #define macros can be exported:

Simple preprocessor defines can be exported as global variables, e.g.:

    #define MYLIB_VALUE 1
    #define MYLIB_FLOAT 1.5
    #define MYLIB_STRING "abc"
    #define MYLIB_HEX_VALUE 0x00010009

This is limited to simple defines.

You can also apply a simple renaming to the macro value: see example below.

Loading...

Set numeric macro values

Sometimes, it is necessary to tell litgen the value of certain numeric macros. In the example below, the member values can be exposed as a numpy array, but litgen needs to know it size.

We set it via the option:

    options.srcmlcpp_options.named_number_macros["MY_COUNT"] = 256
Loading...