Project Level Defines

If it doesn’t already exist or is in the pipeline I would very much like to see project level defines.

Right now I am working on a project with numerous files and it is a bit of a pain to have to edit each one to turn enable, say, “debug” code.

Being able to define items at the project level would mean setting my “debug” define in one place (the project) and have it testable in all files of the project, hopefully library files as well.


You may be interested in the Python program that I have written to manage the compiling and uploading of my Arduino programs. I don't use the Arduino IDE, but the Python program calls it to do the hard work.

The idea behind the Python program is that it takes the files required to compile a program and copies them into a temporary directory structure of the style required by the Arduino system. This means I can choose my own locations for the files while I am editing them. For example I don't need to have the file myProgram.ino in a directory called myProgram.

I suspect it would not be too difficult to adapt the Python program to accommodate the sort of thing you want.


There have been multiple attempts to get this feature added in various forms but all have been rejected, for example: The logic seems to be that not allowing this forces the library developers to create more beginner friendly APIs but sometimes you just need the preprocessor so I think this would be a very useful feature. Interestingly the .org folks have recently added this feature to their IDE

The only solution I've found is to do the define in the sketch before the include and then move all code that depends on that define to the .h file. An example of this used for switching debug output is Another somewhat related technique is that you can set defines with a custom tools menu but this is board dependent so probably not useful to your application. An example of this is: