0

External variables are not listed by "nm" command because they have been declared as extern so memory for them will not be allocated in this program. Is there any other way to list extern variables? Where stored information about external variables declaration?

os windows 7 compiler mingw or vs2010

4

1 に答える 1

3

それらはそこにあり、未定義の U とマークされています。

extern int foo;
int bar() {
  return foo++;
}

与えます:

g++ -c test.cc
nm test.o
00000000 T_Z3barv
         うふふ

barこの例が機能するには、 が必要であることに注意してください。変数が使用されていない場合、出力で参照は生成されません。

于 2012-08-14T10:48:23.170 に答える