No description
ee1f3acf7b
Anonymous namespace should be forbidden in header files even for the forward declarations: * As declarations defined in anonymous namespace are internal linkage, each translation unit which includes this header will get unique copy, which wastes space. * It is easy to violate C++ ODR rule. Consider the following "foo.h": ```cpp namespace { class Foo; } class Bar { public: Foo* getFoo(); Foo* foo; } ``` If the 'foo.h' is included in multiple `.cc` files, the compiler will put `Foo` into a different anonymous namespace in each `.cc`, which means there are different definitions of `Foo` in the program (a violation of the ODR). |
||
---|---|---|
brightray |