Compiler options

I need to change some compiler options for my project. For example, I need to add the
-fno-keep-static-consts
option to the compiler to reduce my memory footprint. I can find no way to add this.

The documentation of the preferences.txt appears to be nonexistent, which strikes me as remarkably irresponsible. How do I set warning options other than "default"? How do I add compiler options like the above? Every possible option should be documented. This is not rocket science; I have done this sort of thing for years for programs I have written. Someone who knows preferences.txt should document this so the rest of us don't have to reverse-engineer what is going on, particularly if that involves reading the source code of the IDE. Having a preferences.txt is useless if it is impossible to figure out how to use it, which, from the vague one-page description I found, is the current situation.

Is there anyone who has written something about this? And if so, why is that not referenced or included in the totally useless "preferences.txt" documentation I find here?
joe

flounder:
And if so, why is that not referenced or included in the totally useless "preferences.txt" documentation I find here?
joe

Because that's not the right file for this. You want the third party hardware specification.

Yeah documentation is a little lax. But that's not the fault of anyone here.

If it really makes you that upset then what you should do is delete the program from your computer and get avr studio. Or look for some other program that costs money. The ones that cost money are usually way better documented than the stuff you get for free. For obvious reasons.

flounder:
The documentation of the preferences.txt appears to be nonexistent, which strikes me as remarkably irresponsible. How do I set warning options other than "default"? How do I add compiler options like the above? Every possible option should be documented. This is not rocket science; I have done this sort of thing for years for programs I have written. Someone who knows preferences.txt should document this so the rest of us don't have to reverse-engineer what is going on, particularly if that involves reading the source code of the IDE. Having a preferences.txt is useless if it is impossible to figure out how to use it, which, from the vague one-page description I found, is the current situation.

Is there anyone who has written something about this? And if so, why is that not referenced or included in the totally useless "preferences.txt" documentation I find here?
joe

Once you have found the answer to your question you can do the rest of us using this 'free' software a favor and update the documentation for us.

Well volunteered.

I need to add the "-fno-keep-static-consts" option to the compiler to reduce my memory footprint.

Really? I'm pretty sure that's either the default, is implied by the optimmization setting, and/or is obviated by the -fdata-sections/--gc-sections combo that the Arduino IDE passes to the compiler/linker.

If you think you want to modify the compiler options, then you are not the target audience of the Arduino project and you should use a different IDE. Arduino is mostly for people who don't even want to know what a compiler is, and for projects that will work without changing the options. Various "full-featured" "professional" IDEs have add-ons to support parts of the Arduino infrastructure: eclipse, Xcode, Atmel Studio, Visual Studio, and more...

Well, here it is, two years later, and I have the same needs, and I fail to understand why something as simple as "command line options" could not be added to the IDE, or we are told how to create new "Boards" files so I can have a board like "Arduino Uno (Optimized Code)". Saying that I don't need a facility because you don't think it will help is not really an option. The number of newbie programmers who would benefit from the -E option is very large, but most of them don't know it exists. Yes, I have used C since 1975, and I have been a Microsoft MVP in C++, which means I can help newbies, but only if I have some controls over the compiler. The amount of effort required to add -E, for example, is minimal. I'd do it myself, but someone who works in the compiler on a daily basis could probably add it in ten minutes; it would take me several days to figure out where to put the code, because I would need to know how to create a control in preferences, or create a dialog of compiler options, and then figure out where to put the code to create the command line. OTOH, if someone could help me, I could do a lot. I have a half-dozen ideas, but need an introduction to the source.
joe

I'm curious.

-E Stop after the preprocessing stage; do not run the compiler proper. The output is in the form of preprocessed source code, which is sent to the standard output.

How do newbie programmers benefit from just running the preprocessor?

Two years and you’ve put in zero work to document these things and you’re still just bitching. Well you’re certainly no help.

[Arduino Install Dir]/hardware/arduino/avr/platform.txt

compiler.cpp.flags

Just did a text search in all files for what I saw it passing. I did notice, though, that certain core files did not receive these options when being compiled, but my library did, so now I can use C++14 instead of C++11, yay. (that's -std=gnu++14 instead of -std=gnu++11 btw)

For searchability, let me also say, I needed to do this to initialize a constexpr fixed length array to pass to a constructor. I couldn't reckon any way under C++11 to initialize an array like that within a single return statement, so I had to declare an array variable, initialize it with other constexpr values, and then pass it to an object constructor in the return statement.

1 Like

Do you think only newbies are using Arduino? To have a readily option to set/change compiler flags for advanced user doesn't hurt anybody :wink:

1 Like

I note for the IDE maintainers:

Is that really hard to add an option to the IDE's Preferences entry menu in which the user can add its own compiler flags? Or to have a special window where you show the options and the user can set/unset them?

I hate Java, that's way in this regard I'm out :slight_smile: