Demo for http://stackoverflow.com/q/16092520/827263
As you can see, g++ 4.7.2 reports the missing semicolon error in c.c, not in foo.h
Demo for http://stackoverflow.com/q/16092520/827263
As you can see, g++ 4.7.2 reports the missing semicolon error in c.c, not in foo.h
| // ; |
| #!/bin/sh | |
| echo "% g++ --version" | |
| g++ --version | |
| echo "% head foo.h bar.h c.cpp" | |
| head foo.h bar.h c.cpp | |
| echo "% g++ -c c.cpp" | |
| g++ -c c.cpp |
| % g++ --version | |
| g++ (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2 | |
| Copyright (C) 2012 Free Software Foundation, Inc. | |
| This is free software; see the source for copying conditions. There is NO | |
| warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
| % head foo.h bar.h c.cpp | |
| ==> foo.h <== | |
| extern void func() | |
| ==> bar.h <== | |
| // ; | |
| ==> c.cpp <== | |
| #include "foo.h" | |
| #include "bar.h" | |
| int main() { | |
| func(); | |
| } | |
| % g++ -c c.cpp | |
| c.cpp:3:1: error: expected initializer before ‘int’ |
| #include "foo.h" | |
| #include "bar.h" | |
| int main() { | |
| func(); | |
| } |
| extern void func() |