[SOLVED] - Precompiler #ifdef's no longer functioning

Earlier in the week, my teammates and I were working on some Photon software. We have an option for a debug mode where the usb cable is plugged in and serial messages are spit out over the USB. During production, the photon is powered by an external line and no serial statements are sent. You could invoke the debug mode by using

#define DEBUG_FLAG

In the code’s body of main.ino, we had several places where print statements would be executed based on

    Serial.println("print state info here");

This was working as of a few days ago (over the weekend). Recently we have run into issues though were these print statements are never executed. We used the cloud compiler to produce two binaries, one with #define DEBUG_FLAG and one without that define line (commented out). and the cloud produced two executables that are identical. (Running diff with_debug.bin without_debug.bin produces no difference.)

Was the particle cloud changed recently or am I missing something?

Have you tried any other valid name for your file besides main.ino?

Hi BulldogLowell!

No, we haven’t tried anything else beyond main.ino. Do you think that would make a difference?


  • Matt

@mattmcf, if both executables are the same then somewhere, DEBUG_FLAG is being defined. You should review your code (or post it) carefully.

One quick test of the compile flags is to add a #error “why am I here” in your code for example.

The last change to the compiler rolled out on February 15th.

If you would like to send me your code through a private message I can see if the change affected your code.

1 Like

Hey All,

Thanks for your suggestions and help - we realized the error.

There was a nested directory in our project folder that also contained a main.ino file. Although we had not run into problems previously with that nested folder, when we renamed the top-level main.ino to program.ino, we suddenly saw the compiler returning errors for the subdirectory/main.ino file. We didn’t realize that the subdirectory’s files were getting pushed to the cloud compiler. It seems like the subdirectory’s main.ino code was superceding the top-level setup() and loop() functions but the compiler wasn’t returning warnings that setup() and loop() were doubly defined.

By moving the subdirectory project out of the top directory, we have regained our determinacy - #ifdef works as expected now. Sorry for the misdirected diagnosis.


  • Matt
1 Like