List all used pre processor definitions

Hi,
is it possible to show / list all used pre processor definitions used during a compilation?
Background: I'm writing a sketch for ESP32 and I like to have a check for the IDF version, also for the selected hardware. So using something like
#ifdef ARDUINO_ARCH_ESP32
for the Arduino IDE version and and the Espressif IDF version is needed.

A list with all used definitions might also be helpful for other topics.

Regards
Nils

You can add these #ifdef to your code and eventually generate warnings showing the actual values.

Listing the used preprocessor directives will require to dig into the lexer. Some time ago I wrote a parser that could be used for that purpose, but I doubt that a compiler will hold such information.

You may also find something in this thread: Multi-Architecture libraries. Determining target platform or board type

GCC has these predefined macros:

To list all current macros, use -E -dM:

from:

via: gcc list defined macros - Google Search

Thank you, but I'm looking for the used definitions in the current project.
I found one which is usefull for my current ESP32 project:
IDF_VER
This is set to the used Espressif IDF version installed in the Arduino IDE. Since I try something with Bluetooth I need to make sure at least 4.4.1 because there should a bug be fixed.
So now I can stop if the version is lower than 4.4.1 (or in a simple way I just print out the version to see I'm using a newer one... :wink: )

Regards
Nils

-E -dM would give you that

1 Like

I suspect that you really want to know the existing (#defined) macros. Macros are not "used" unless they are used in code, not only defined.

The docs of each library should mention which macros are #defined by the library and what's their meaning.

Hi, thank you, this is the option I need.
The only hard thing is currently to get the huge command into a command line, maybe I can test this on a Linux installation, Windows is not able to handle this from my current project... :frowning:

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.