While reading Is this proper C declaration? If so, why does it not work? I was thinking about
#include <stdio.h>
int main(void) {
int bool = 0;
return bool == 0;
}
Is this program strictly conforming? In other words, is stdio.h
allowed to include stdbool.h
or is it forbidden to do so? Is this specified by the spec?
Your #include s should be of header files, and each file (source or header) should #include the header files it needs. Header files should #include the minimum header files necessary, and source files should also, though it's not as important for source files.
As a rule, put your includes in the . cpp files when you can, and only in the . h files when that is not possible. You can use forward declarations to remove the need to include headers from other headers in many cases: this can help reduce compilation time which can become a big issue as your project grows.
C standard headers can not include other headers. This is different from C++, where it is explicitly allowed.
C99 standard, section 7.1.3
Each header declares or defines all identifiers listed in its associated subclause[...] No other identifiers are reserved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With