http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52566
Bug #: 52566 Summary: #include in c++ namespace scope doesn't work properly Classification: Unclassified Product: gcc Version: 4.4.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor AssignedTo: unassig...@gcc.gnu.org ReportedBy: shi...@gmail.com # gcc --version gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3 3 source files: ns1.h ns2.h test.cpp --------------------------------------------------------- ns1.h: #pragma once class A { }; --------------------------------------------------------- ns2.h: #pragma once class A { }; --------------------------------------------------------- test.cpp: namespace NS1 { #include "ns1.h" } namespace NS2 { #include "ns2.h" } int main() { NS2::A a; return 0; } --------------------------------------------------------- # touch * // important step, let ns1.h and ns2.h have same modification time # gcc test.cpp test.cpp: In function 'int main()': test.cpp:11: error: 'A' is not a member of 'NS2' test.cpp:11: error: expected ';' before 'a' # gcc -c -E test.cpp # 1 "test.cpp" # 1 "<built-in>" # 1 "<command-line>" # 1 "test.cpp" namespace NS1 { # 1 "ns1.h" 1 class A { }; # 4 "test.cpp" 2 } namespace NS2 { } int main() { NS2::A a; return 0; } ---------------------------------------------------- The NS2::A declaration isn't included in namespace NS2