When to use include guards?
问题 I know that the use of include guards in header files is to prevent something from being defined twice. Using this code sample though, was completely fine: foo.c #include <stdio.h> #include <string.h> #include "bar.h" int main() { printf("%d", strlen("Test String")); somefunc("Some test string..."); return 0; } bar.h #ifndef BAR_H_INCLUDED #define BAR_H_INCLUDED void somefunc(char str[]); #endif bar.c #include <stdio.h> #include <string.h> #include "bar.h" void somefunc(char str[]) { printf(