This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SDK-16 - NRFX_CHECK(module_enabled) (module_enabled) - How this MACRO works?

Hi everyone,

When we want to enable a module we usually enable it from the sdk_config.h by setting the desired module to 1 (for example #define NRFX_SAADC_ENABLED 1). I am trying to understand how the module is enabled and found that the responsible macro is the following located in nrfx_common.h file

#define NRFX_CHECK(module_enabled)  (module_enabled)

How does this macro works? I cannot understand this syntax. How it checks that the module is enables or not?

Thanks in advance

Nick

  • Hi,

    This macro is not used for enabling the module itself, it is used in combination with the #if syntax to include/exclude code based on if the symbol is set or not. This macro is used for suppressing potential warning from checking undefined symbols, as mentioned in the API documentation:

    "Macro for checking if the specified identifier is defined and it has a non-zero value.

    Normally, preprocessors treat all undefined identifiers as having the value zero. However, some tools, like static code analyzers, can issue a warning when such identifier is evaluated. This macro gives the possibility to suppress such warnings only in places where this macro is used for evaluation, not in the whole analyzed code."

    As you can understand, this macro only defines the symbol and sets it to 0 if it is not defined in your sdk_config.h file or preprocessor symbols.

    Best regards,
    Jørgen

Related