Nested anonymous namespace?

前端 未结 2 1020
盖世英雄少女心
盖世英雄少女心 2021-02-06 22:54

When using an anonymous namespace are there any issues if it is nested within another namespace? For example, is there any real difference between Foo1.cpp and Foo2.cpp in the

2条回答
  •  日久生厌
    2021-02-06 23:26

    Probably no real difference for your purposes. It makes a difference to where in your cpp file privateFunction is visible. If you add void barFunc() { privateFunction(); } to the end of both files, then Foo2.cpp compiles and Foo1.cpp doesn't.

    Normally you wouldn't define external symbols from lots of different namespaces in the same cpp file, so the difference won't come up.

提交回复
热议问题