Request for Arduino IDE "extra_flags" support

shawn

Well-known member
The problem

I need to add compiler options to a project to enable some features. For example, QNEthernet needs the `QNETHERNET_ENABLE_RAW_FRAME_SUPPORT` macro defined in order to enable the raw frame feature. To try this out, check out the _RawFrameMonitor_ example.

There's no easy way to do this in the Arduino IDE. Currently, the suggested way to add compiler options to the Arduino IDE build is to add a _platform.local.txt_ file with those extra options. Refs:
https://forum.arduino.cc/t/additional-compiler-options/631297
https://forum.arduino.cc/t/arduino-ide-where-can-i-pass-defines-to-the-compiler/680845 (uses command-line option)

At first I thought that the IDE just doesn't support this when using Teensyduino. However, it appears that its _platform.txt_ file simply doesn't include a way to override those options.

The fix

To enable support of extra flags in that _platform.local.txt_ approach, Teensyduino's _platform.txt_ file needs to be modified. I've attached a proposed new version of the Teensyduino _platform.txt_ file along with a diff. It attempts to match what the Arduino AVR platform is doing in its _platform.txt_ file with those "extra_flags" options.

Attachments:
View attachment platform_with_extras.txt
View attachment platform_with_extras_diff.txt

Testing

I made the _platform.txt_ file modification, added a
"compiler.cpp.extra_flags=-DQNETHERNET_ENABLE_RAW_FRAME_SUPPORT"
line to a new _platform.local.txt_ file, restarted the IDE (that step seems to be required), and now the build works as expected. The _RawFrameMonitor_ can now build and run correctly.

See also

This discussion inspired me to make this fix:
https://github.com/ssilverman/QNEthernet/issues/33
 
Last edited:
I'm worried this will turn Arduino IDE into the tech support problems we have with PlatformIO. Really want to keep Arduino IDE usage a "known quantity".
 
Back
Top