@megmac C/C++ is a special hell because often you can import a symbol by *accident*. So code will work in one project and then you'll paste it into another and suddenly a critical symbol isn't found, because in the original project you included B.h which included A.h because nobody clearly told you in the first place you needed to include A.h.
Conversation
Notices
-
Embed this notice
mcc (mcc@mastodon.social)'s status on Tuesday, 06-Feb-2024 18:00:02 JST mcc
- clacke likes this.
-
Embed this notice
mcc (mcc@mastodon.social)'s status on Tuesday, 06-Feb-2024 18:00:10 JST mcc
@wollman @airtower @megmac Maybe symbol import by textual inclusion is not actually a good approach
clacke likes this. -
Embed this notice
Garrett Wollman (wollman@mastodon.social)'s status on Tuesday, 06-Feb-2024 18:00:11 JST Garrett Wollman
@airtower @mcc @megmac There was kind of a religious war about this, with different people arguing that either all header files should be self-contained or that no header file should include any other (user-visible) header file, because namespace pollution. POSIX adopted the former, but also introduced a lot of new typedefs which meant that anyone doing anything nontrivial had to follow suit (because C doesn't have incomplete typedefs) even if most clients would never use them.
-
Embed this notice
Fiona :heart_trans: (airtower@queer.af)'s status on Tuesday, 06-Feb-2024 18:00:12 JST Fiona :heart_trans:
@mcc @megmac Or B.h uses a symbol declared in A.h but doesn't explicitly include it. If you include A.h then B.h it works, if you include B.h first you get implicit declarations and things break in weird ways.