Skip to content
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

Docs: add an entry about compiler warnings #8492

Merged
merged 3 commits into from Feb 22, 2022

Conversation

mcspr
Copy link
Collaborator

@mcspr mcspr commented Feb 20, 2022

per #8421 and #8475
after checking HW, suggest to check SW as well at least by enabling compiler warnings
(and also note of the IDE weirdest defaults causing issues we expected to stay solved)

Copy link
Collaborator

@d-a-v d-a-v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was missing.

@earlephilhower
Copy link
Collaborator

earlephilhower commented Feb 20, 2022

Don't we always generate a warning/error on this case, even with None? If not, I think we can fix it instead of documenting it, by changing the platform.txt options...

compiler.warning_flags.none=-w -Werror=return-type

@mcspr
Copy link
Collaborator Author

mcspr commented Feb 21, 2022

only 3 out of 4 options produce error:

Arduino/platform.txt

Lines 24 to 28 in 15e7d35

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

'None' never does, -w overrides any -W flags since they apply all at once and not like 'disable all warnings but still enable this one', order does not matter. Removing -w from 'None' kind of defeats the purpose of the option, and there is 'Default' for that.

We do still need to mention the warnings, which even in 'Default' will give some useful advice. Specifically with C++, shouldn't we mention that it is undefined behaviour when trying to code like that?

btw low-level routines that really do not return may still be coded like this

int func() {
  __builtin_unreachable();
}

@earlephilhower
Copy link
Collaborator

Argh, you are correct. Even trying to explicitly enable a warning like -w -Wreturn-type -Werror=return-type doesn't work.

It seems the only way to make this automatically catch is to not use -w and specifically list all ~100 -Wno-XXX in an @option file. While doable, that's more involved than I have time for this AM...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants