Arduino IDE > Tools Setting queryable via C Code?

Andreas

Member
In Arduino IDE it is possible under Tools to adjust certain settings, e.g. Optimize (Smallest Code), CPU Speed (600 MHz), USB Type (Serial+Midi+Audio).
I wonder if these settings are queryable via C/C++ code?

Thank's for any hints.

Andreas
 
For many of these you can have your code check depends.

If you have not already done so, you might turn on verbose compiles (preferences). Then you can see the command lines generated.

For example: sketch I am running right now:
Code:
"C:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\tools\\teensy-tools\\1.58.0-beta2/precompile_helper" "C:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\1.58.0-beta2/cores/teensy4" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino-sketch-8B8058E8087E9238B89B1BD81ABB3B19" "C:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\tools\\teensy-compile\\11.3.1-beta1/arm/bin/arm-none-eabi-g++" -x c++-header -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=158 -DARDUINO=10607 -DARDUINO_TEENSY_MICROMOD -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\1.58.0-beta2/cores/teensy4" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino-sketch-8B8058E8087E9238B89B1BD81ABB3B19/pch/Arduino.h" -o "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino-sketch-8B8058E8087E9238B89B1BD81ABB3B19/pch/Arduino.h.gch"
Using previously compiled file: C:\Users\kurte\AppData\Local\Temp\arduino-sketch-8B8058E8087E9238B89B1BD81ABB3B19\pch\Arduino.h.gch

In this for example you see for USB Type: -DUSB_SERIAL
So your code can do stuff like: #ifdef USB_SERIAL

Speed: -DF_CPU=600000000
So you can look for the value F_CPU

As for optimizations not sure, those are direct switches to compiler like -O2
There may be ways, but...
 
Back
Top