-
-
Notifications
You must be signed in to change notification settings - Fork 431
Enable "Compiler warnings" preference by default #1630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You miss the passage from "totally unable to write a sketch" to "novice". Warnings are unnecessary to the formers and, classes prove, scare them away. Becoming a novice is a big achievement, while going from novice to expert it's just a matter of time and dedication. |
Sure, but if Setting Again, this should be highlighted in bold on the Arduino website somewhere, because when I see libraries emitting warnings, I know the authors also didn't see them. This isn't just about the novices, this is about the ecosystem of code and advanced users around them too. |
Don't get me wrong: I would turn on warnings by default without giving users an option to turn them off! However, we have to deal with a ton of already written documentation/books/blogs/tweets/you name it, which (precisely or not) shout out loud what are the side effects of each and every button/checkbox/menu. This is why we have two distinct options for turning on verbose output and warnings (verbose output is usually used to find out where the IDE has saved intermediate files) |
That would be awesome. I had used the verbose output to view the commands used, but yes the default assumption that warnings would be provided, that's what caught me off guard. In this case, I think more detail would be better, otherwise, verbose output isn't as helpful as it could be. I think one underlying reason why warnings are off by default is GCC not having very clear warnings (to novices anyways). Even advanced users usually have to read those warnings twice, just to figure out what the hell GCC is talking about. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@ffissore, I would ask to reconsider this ticket. I asked the original reported to report it after this got mentioned in another issue. While adding the warning option, we discussed that it would be good to enable warnings by default, at least for the sketch itself (i.e. so only warnings that the user should be able to fix are reported, unlike warnings in the core and library which are effectively opaque to novice users). Also, we considered making a selection of warnings that are clear and easy to fix, and keep the complex warnings disabled by default. We initially didn't implement this, just to get the warning option out there sooner and perhaps collect some feedback, but I still feel that implementing something like this so we can enable (most) warnings by default is important and should be tracked in this issue. |
This has been discussed in detail before. Please see arduino/Arduino#1728. |
Although I don't think -Wextra should be enabled by default since as ffissore said it might scare newcomers, I think the -Wall flag would solve a lot of common problems.
In other words, -Wall is not really THAT scary; most of the time it indicates actual mistakes. -Wextra is a bit more paranoid and gives many "false positives", so it's probably not a good idea to enable it by default. And in any case, the default warnings (with no -Wall nor -Wextra) are only the REALLY problematic ones, so at the very least I'd remove the -w option. Also, not using -Wall hides some potential misbehaviors, such as signed overflow:
When compiled with -Wall, this shows: |
This comment was marked as resolved.
This comment was marked as resolved.
I've mentioned this before on the mail list, but not here... Teensy's platform.txt file enables -Wall for the sketch and all libraries. I also patch Compiler.java to print the only actual errors in red. The compiler's warning output is printed in the same white text as everything else. At least for Teensy, which admittedly has a very different user base than official Arduino boards, this trade-off has worked quite well. I'd be happy to submit a pull request, if there's a solid decision to go this route. |
This comment was marked as duplicate.
This comment was marked as duplicate.
I believe that some changes ought to be made in this regard:
|
@matthijskooijman - Could the builder become smarter to try to detect the difference between library authors and ordinary end users? Perhaps if the library source files change more than once (or twice?) after installing or upgrading the library, some sort of state could be saved to remember that particular library is under development? Then the builder could suppress warning for ordinary end users, but show them loudly to the author or any maintainers of that library.... Ideally, this could be done on a per-library (and core lib) basis, so the author of a particular library is only pestered by warnings related to their own code. |
My idea was to (effectively) configure this in the preferences, by letting people (i.e. library authors) enable warnings in libraries, which are disabled by default. Autodetecting this based on library changes is interesting, but also prone to misfires and unexpected behaviour (user suprise)... |
What about re-using the |
For clarity, let me write down what I had in mind when writing #1630 Wrt warnings, I would distinguish three areas: Sketches, libraries and cores. By default, warnings would be enabled for sketches, but not for libraries and cores, which facilitates the most common case of a (novice) user writing sketches, but not libraries or cores. For users that write libraries or cores, we can expect some action to enable warnings themselves. In terms of UI, I can imagine two variants:
The former is more flexible (allows different warning levels for different areas, or allows enabling warnings for e.g. cores but not libraries), but might also be slightly more complex for users (OTOH, it does seem easy to understand to me). This distinction can be implemented in the IDE / arduino-builder, I believe this requires no changes in platform.txt. The second (and IMHO separate) part of the proposal was to add an extra warnings level "Selected warnings" or "Novice warnings" something like that, in which we enable a selected subset of warnings (rather than relying on some compiler-defined subsets). This subset would be picked by reviewing each individual warning and considering the merits of the warning, as well as the potential to confuse novice users. This subset would probably need to be defined in platform.txt, since it couples tightly with the compiler (version) used. This proposal does not automatically differentiate between library authors and normal users (as suggested above) but lets users make this choice themselves (defaulting to novice sketch-only users). To add that (either fully automatic or using the |
For an even simpler approach re: the GUI, I'd just add an Include warnings from core/library components checkbox rather than a dropdown menu with 3 options, unless it is really considered necessary to hide core warnings to library developers. Since some users may not be OK with such a limited subset, there could be an "Advanced..." button or "Custom" option that opens a dialog where the user can enter their own flags manually (either by typing them or by selecting them from a list), for each of the three parts. I think this would be the best approach, since it provides high customization without interfering with the GUI simplicity. Finally, I would like to suggest doing some sort of processing of the warning types (as indicated by the |
This has been open for nearly 9 years now, and I raised a new issue #2316 which just got closed as a duplicate. Is there a reason it hasn't been fixed yet? It seems like a fairly simple change to make, with no downsides and clear benefit for the platform.
To be clear, the request is to change this setting to "Default" generally, whether for cores, sketches, etc. Whether people choose to ignore the warnings or manually bump the level up to "-Wall"/"-Werror" should be entirely up to them, but they should have a chance to see these basic warnings first and potentially fix their mistakes. The default set of GCC warnings should suffice for most usecases (which is why they are default, in the first place), an okay balance for the platform. I don't see any reason why warnings would be any more scary than errors, which users already see and have to fix, so this shouldn't be an argument. At worst, a user sees some warnings from some library (which compiles just fine) and if they're at all worried, they search or raise a question on some Q/A site where people explain whether the warning is harmless or not -- and/or better yet, they'll raise an issue against the library to find out what's going on, which should in time prompt authors to fix these things or find other ways to do stuff that don't provoke warnings. This is certainly better than the silent alternative where you spend ages trying to figure out why your device is crashing, when a simple warning would've told you or provided hints immediately. |
I think this was never fixed due to lack of consensus. Some views were that defaulting to Overall, I think that at the very least Arduino shouldn't purposefully disable "natural" warnings, and if a user triggers such a warning it probably means they did something catastrophic and should know about it - after all, Arduino is meant for learning. |
Yeah, there's no consensus on The default set is already a good default, whether for sketches, libraries, etc., this doesn't need to get terribly complex. I hope it can get resolved soon and doesn't hang around for another decade. |
Describe the request
Enable compiler warnings by default by changing the default value of the "Compiler warnings" preference.
🙂 Important information about potential problems in Arduino code will be visible to more Arduino IDE users.
🙂 Developers of shared Arduino projects will be encouraged to write warning-free code
Describe the current behavior
The default value of the "Compiler warnings" preference is "None"
🙁 Users might suffer from bugs that are difficult to troubleshoot without assistance from the compiler.
🙁 Developers of shared Arduino projects are not aware that their code produces warnings and so don't fix them. These warnings then make it more difficult for users of dependent projects who do enable warnings to differentiate the warnings in their own code from the warnings from the dependencies.
Arduino IDE version
Original report
1.6.6
Last verified with
73b6dc4
Operating system
All
Operating system version
Any
Additional context
Defaulting to not showing warnings is, overall, a bad thing for the ecosystem. Advanced users will have a hard time taking it seriously, when instead of owning the errors, the IDE sweeps them under the rug.
Additional requests
Issue checklist
The text was updated successfully, but these errors were encountered: