Ling-hua Tseng wrote: > If I compile this file with g++ 4.2 by the following command: > g++ -c test.cxx > and then use this command to check symbol: > nm test.o > I cannot find the global varible `test' in symbol table:
This was an intentional change as part of the overhaul of C++ visibility semantics in 4.2. The motivation for this aspect of the change comes about from the realization that anonymous namespaces are implemented by adding a randomly-generated string to the mangled name so that they're guaranteed to be unique to their translation unit. So it would be impossible or at least extremely cumbersome to actually refer to such a symbol from another module, and thus giving them hidden visibility just cuts down on useless indirection and overhead. http://gcc.gnu.org/gcc-4.2/changes.html http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21581 http://gcc.gnu.org/ml/gcc-patches/2006-06/msg01511.html http://gcc.gnu.org/ml/gcc-patches/2006-03/msg01322.html Brian