You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In C, if A.c #includes B.h, and B.c #includes C.h, then the symbols declared in C.h will be available in A.c. (Nope, this was a misconception. But indirect header dependencies are still a pest for compilation.) Depending on this behaviour makes locating definitions when reading source a potentially recursive process, as well as making compilation inefficient when abused on a large scale1. My proposal is for a warning that would catch this behaviour, encouraging explicit #includes if a symbol is to be used.
This warning trips if a symbol is used which is not declared in the same file or in a header explicitly #included in the file. The symbol need not be defined in these, only declared; this means C projects written with best practices will compile the same way with no additional warnings.
- "Make headers standalone": over 80 headers don't build standalone and
depend on various accidental indirect dependencies they gain through
other headers, especially once headers get their unnecessary dependencies
removed. So there's over 80 commits changing these headers.
ghost
changed the title
Proposal: -fstrict-headers mode to limit symbol visibility within a compilation unit
Proposal: -Windirect-include for use of a symbol not declared in the same file or an explicitly included header
Feb 5, 2022
ghost
changed the title
Proposal: -Windirect-include for use of a symbol not declared in the same file or an explicitly included header
Proposal: Warn for use of a symbol not declared in the same file or an explicitly included header
Feb 5, 2022
I did not know about this option, I love it! (Oh wait, it sounds like it doesn't exist and you're suggesting it be added, in which case I love the proposal!)
In C, if A.c(Nope, this was a misconception. But indirect header dependencies are still a pest for compilation.) Depending on this behaviour makes locating definitions when reading source a potentially recursive process, as well as making compilation inefficient when abused on a large scale1. My proposal is for a warning that would catch this behaviour, encouraging explicit#include
s B.h, and B.c#include
s C.h, then the symbols declared in C.h will be available in A.c.#include
s if a symbol is to be used.This warning trips if a symbol is used which is not declared in the same file or in a header explicitly
#include
d in the file. The symbol need not be defined in these, only declared; this means C projects written with best practices will compile the same way with no additional warnings.Footnotes
https://lkml.org/lkml/2022/1/2/187 ↩
The text was updated successfully, but these errors were encountered: