代码之家  ›  专栏  ›  技术社区  ›  Ricko M

对象文件中的外部符号

c c++
  •  1
  • Ricko M  · 技术社区  · 15 年前

    我面临着一个奇怪的问题,但无法用更小的尺度来模拟。问题是我的符号表有一个外部符号条目。它们在头文件中声明。在其他文件头.c中定义

    头文件

    header.h
    
    extern void rlog(int , char*, ...);
    extern int SetGDebug(string);
    extern int GDebug;
    

    测试.cpp C++文件

    #include <header.h>
    
    nm -CA test.o | grep De
    
    00000000 B GDebug
    00000b70 t global constructors keyed to GDebug
    00000070 T SetGDebug()
    

    编译标志:-Wall-O2-shared-fPIC-funroll循环 编译器:g++

    另一个简单的问题。。。

    外部nd符号/函数是否进入对象文件的符号表?

    1 回复  |  直到 15 年前
        1
  •  1
  •   Puppy    15 年前

    不需要声明外部函数,只需要声明变量。