Compiler warnings not suppressed

V2.0.3 Pop!OS 22.04 (Ubuntu derivative)
Compiler warnings = None

I am getting a flood of compiler warnings, although the setting is None. Is this expected behavior?
Example:

/home/bruce/Arduino/ELS_IDE2/touchdisplay.ino: In function 'void processTouch()':
/home/bruce/Arduino/ELS_IDE2/touchdisplay.ino:726:29: warning: unused variable 'mydatum' [-Wunused-variable]
               x=40; uint8_t mydatum = BC_DATUM;

I can barely find the errors due to warnings. I would expect a None setting would result in no warnings. Default would add warnings. Either that or eliminate None. None means none = 0 warnings, at least to me.

I am utterly astonished that a perfectly working IDE 1.8.19 project can't even compile on IDE 2. I don't know what to do, save for reversion.

In the future, it would be nice to highlight the errors! Right now the Output stream is mono color. It would be good if the Output font color is selectable. I find the default setting is difficult for me to read. There is insufficient contrast for this color. Maybe if I could make the red slightly more saturated?

Each boards platform author has complete control over the effect of the "Compiler warnings" preference. Some of them have chosen to force warnings to be shown even when it is set to "None", likely because they feel that compiler warnings are important and should be paid attention to and resolved rather than hiding the problems away by suppressing them.

For example, why do you have this unused variable? If it serves no purpose, why not remove it? If it was intended to serve a purpose but is not being used, then this indicates there is a bug in your code.

I'm going to ask you to post some additional information that might help us to identify the problem.


:exclamation: NOTE: These instructions will not solve the problem. They are only intended to gather more information which might provide a clue that eventually leads to a solution.


Please do this:

  1. Select File > Preferences from the Arduino IDE menus.
  2. Check the box next to "Show verbose output during: ☐ compilation".
  3. Click the OK button.
  4. Select Sketch > Verify/Compile from the Arduino IDE menus.
  5. Wait for the compilation to fail.
  6. You will see a "Compilation error: ..." notification at the bottom right corner of the Arduino IDE window. Click the COPY ERROR MESSAGES button on that notification.
  7. Open a forum reply here by clicking the Reply button.
  8. Click the </> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block
  9. Press Ctrl+V.
    This will paste the compilation output into the code block.
  10. Move the cursor outside of the code tags before you add any additional text to your reply.
  11. Click the Reply button to post the output.

In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here:

  1. Open any text editor program.
  2. Paste the copied output into the text editor.
  3. Save the file in .txt format.
  4. Open a forum reply here by clicking the Reply button.
  5. Click the "Upload" icon (image) on the post composer toolbar:
    image
  6. Select the .txt file you saved.
  7. Click the Open button.
  8. Click the Reply button to publish the post.

Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.

They should be highlighted. There is a pink background color added to the line in your sketch associated with an error.

That is odd. The warnings and errors should be red. The rest of the output text should be white.

The developers are tracking the need to make that red brighter here:

If you have a GitHub account, you can subscribe to that issue to get notifications of any new developments related to this subject.

But you can do something about it right now. Arduino IDE comes with a special high contrast theme that is specifically designed for people who have trouble with the contrast of the normal themes. I'll provide instructions you can follow to activate it:

  1. Select File > Preferences from the Arduino IDE menus.
  2. Select "High Contrast (Theia)" from the "Theme" menu.
  3. Click the "OK" button.

Thanks for your complete and thoughtful answer. I think I was a bit taken aback by the sheer amount of errors that a fully functional project generated. I believe some of this was due to the fact that the IDE2 installed over existing user libraries, in my /Arduino/libraries subdirectory. This is problematic. It means that IDE2 and IDE1 don't coexist, because the install altered libraries. I have sorted though some of the issues. This is in a product that I have shipped, and am still alarmed that I cannot even compile my formerly working project. However, I am slowly sorting through the issues.

Some of the issues are occasional unused variables, which I should hunt down and eliminate. They don't belong there, but on the other hand don't break function. I do have some warnings about a way that I am writing to a display (ILI9341). I need to fix that, but I will ask for advise in a different sub forum. The last major issue is a conflict between libraries. It seems a font package is also bringing in another library, which I didn't expect.

Thank you for the advise to try high contrast. It's not actually a very high contrast, but the contrast is sufficient for me. It makes the Output area easier to read. The colors are reasonable and pleasant.

No errors were highlighted in the code. No pink or anything else.
Version: 2.0.3
Date: 2022-12-05T09:27:52.215Z
CLI Version: 0.29.0 [76251df9]

Copyright © 2023 Arduino SA

On the right hand side of the Output screen, on the scroll bar there is a very small grayish tick. It is very subtle. That is the only indication of an error on my screen. I didn't even notice it until just now. The error and warnings are a low contrast red. Unless you read the wall of words, you cannot tell the difference between them. From a human factors point of view, I'd expect errors to stand out compared to warnings. After all, they are errors - why not make them easy to find?

I'd love to post all my code, but I'm afraid there's too much stuff. I have 2064 LOC. At some point I will open source this, but not until I test it further. My customer, is doing some testing, being a willing participant in the process. The code is for an electronic lead screw controller for a lathe, so I want it to be robust and reasonably safe. Or at least as safe as running a lathe can be. The controller includes an integrated touch panel display. I have a complete unit running on my lathe, which was completed in November 2022, using IDE 1.8.19. I have everything backed up on an alternate computer, (an RPI4) but under IDE2.0.3 on my main computer I can't get it to build.

Some of the older beta/"release candidate" versions of Arduino IDE 2.x did, but the installation of the release versions, and even the beta versions that came before the release, do not make any changes at all to those libraries.

From a technical point of view, it is not so easy. Arduino IDE does not actually compile your sketch code. It runs a standard C++ compiler toolchain (typically GCC) and prints the output from GCC to the "Output" panel. The output from the compiler toolchain comes in two streams: standard out (aka "stdout"), and standard error (AKA "stderr").

Arduino IDE prints everything it receives on the standard out stream in white text and everything it receives on the standard error stream in red text. The compiler errors and warning are both printed on standard error.

So in order to color them differently, Arduino IDE would need to have enough of an understanding of this output to differentiate warnings from errors, which is quite a bit different than the current system of letting the tools handle the differentiation of the output. That is not to say it is impossible. Fortunately there is a standard format the compiler output follows , so it is possible for a machine to parse it, even though it is in a format intended for humans to read instead of machines.

No worries. I actually asked for the compilation error output instead of the code. The main reason I wanted to look at the compilation output is to identify which boards platform you are using. That would allow me to provide a conclusive answer to your original question:

Without knowing which boards platform you are using, I can only give the speculative explanation I provided before.

The other thing the compilation output might clarify is this mystery of the libraries being changed and the sketch failing to compile:

It is very unlikely the errors are caused by the change in the Arduino IDE application version itself. It is much more likely they are caused by different dependencies (boards platform and libraries) being used between the two IDE versions. Except for some very rare exceptions, if the compilation uses the same dependencies, then you are going to get the same result regardless of whether you are using Arduino IDE 1.8.19 or 2.0.3. They both run the same compilation commands.

I'm using a Teensy 4.1 for the main board.

I have only installed 1.8.19 (a while back!) and IDE 2.0.3, downloaded and installed yesterday...
My mistake, I guess was allowing updating libraries, when I should have answered No.

Fortunately I have a way to continue maintaining my software. I have a complete working IDE 1.8.19 running on two different RPI4's. My SW is backed up on a private git server.

Still, this is awful. I would not have thought a fully running project would have been brought to its knees, no matter what the reason. What makes this difficult, is I don't know exactly what happened during the install, so it's tough to backtrack.

Note: I don't believe that when building for a Teensy that Paul uses this setting at all to decide which if any warnings should be displayed.

I believe most of the things were hopefully already resolved over on the pjrc forum thread
Arduino 2 IDE coexistance with 1? (pjrc.com)

@KurtE why would a setting in the IDE2 Warnings = None generate warnings? Does PJRC have a defined set of compiler warnings set? Either PJRC or Arduino put in the settings. It sure wasn't me.

Most of the time I normally would use a default setting, since one does want some warnings to happen - especially for some bonehead stuff. But I would expect None means None, which means only errors. Just my opinion. I was quite surprised that the switch didn't work. I can see greying out the choice if the selection is not allowed, but it was displayed as a legal choice. So I expect the setting to be valid, and not to be redefined.

I just took a look at the Teensy platform configuration and I confirm what KurtE already stated. The platform configuration completely ignores the setting of the "Compiler warnings" preference. The -Wall compiler flag is always used. It is hardcoded into this line of the platform's boards.txt file:

teensy41.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib

Ah, yes. That will definitely change your libraries.

Nice!

If you have a working setup on your RPi, it will be easy to determine the dependency versions used on the working system. I would normally get the verbose compilation output from the user and then provide a line by line interpretation, but I know you are not willing to provide that. So I'll give you some general instructions for how you can interpret the verbose compilation output yourself:

At the top of the output, you will see something of this form:

Using board 'teensy41' from platform in folder: C:\Users\per\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.57.2
Using core 'teensy4' from platform in folder: C:\Users\per\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.57.2

The important part here is the name of the version folder. This tells me I am using version 1.57.2 of the Teensy boards platform dependency of my sketch.

At the bottom of the output, you will see something of this form:

Using library FastLED at version 3.5.0 in folder: C:\Users\per\Documents\Arduino\libraries\FastLED 
Using library SPI at version 1.0 in folder: C:\Users\per\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.57.2\libraries\SPI 

This tells me I am using version 3.5.0 of the "FastLED" library dependency of my sketch.

It also tells me that I am using version 1.0 of the "SPI" library dependency of my sketch. However, note the path of the library is inside the Teensy platform. So this means that installing the Teensy platform 1.57.2 also installs the SPI library version 1.0. So I don't need to directly manage the "SPI" library dependency in this case. I only need to manage the Teensy boards platform dependency and that also ensures I will have the specific versions of all the libraries bundled with that platform.

Once you have gathered this information from your working system. Simply use the Arduino IDE Boards Manager to install that same platform dependency version on the non-working system, then do the same using Library Manager for the library dependencies. After that, you should get the same results from compiling your sketch.

I think it will be a good idea for you to document the specific dependency versions the project is intended to be used with.

This is just a fact of life in software development of any type.

If you want a reproducible build, you must carefully manage your dependencies. The developers of the dependencies make changes over time. Those changes can have impacts on the dependent projects

PJRC. The Arduino boards platform framework gives the platform developer complete control over the effect of the "Compiler warnings" preference, including choosing to make it not have any effect.

You can modify the platform if you like. I pointed out the specific line above. The simple fix would be to change the -Wall flag in that line to -w to suppress the warnings:

teensy41.build.flags.common=-g -w -ffunction-sections -fdata-sections -nostdlib

Or if you want to do it right, you can change it to a reference of the compiler.warning_flags platform property:

teensy41.build.flags.common=-g {compiler.warning_flags} -ffunction-sections -fdata-sections -nostdlib

Then add this to the platform.txt file to set the value of the compiler.warning_flags property for each setting of the "Compiler warnings" preference:

compiler.warning_flags.none=-w
compiler.warning_flags.default=
compiler.warning_flags.more=-Wall
compiler.warning_flags.all=-Wall -Wextra

You can choose any specific flags you like here. The snippet above is only a common configuration.

The compiler warning flags are documented here:

Thanks for your complete and thorough answers. It really helps me understand what is going on. Have to admit I was flustered from the initial experience of the conversion. It seems the primary issue was changing the libraries which can be problematic. I'll have to plow through the libraries between the two IDEs and figure out the differences.

And thanks a lot for the tips on "fixing" the compiler warnings. That looks worthwhile doing. I can see why PJRC did it for support reasons, but, it is not my preference at all. None means none... If I wanted all of the warnings, I'd select that option!

You are welcome. I'm glad if I was able to be of assistance.

Regards,
Per

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.