【发布时间】:2021-03-02 15:35:54
【问题描述】:
我使用g++ (7.3.0) 编译了这段 C++ 代码。
struct C {
__attribute__((noinline)) int foo() { return 0; };
};
int bar(C &c) { return c.foo(); }
使用nm 我发现foo 很弱。这是由于 C++ 规范还是 GCC 的决定?
实验流程:
$ g++ test.cpp -c -Og
$ nm test.o
0000000000000000 T _Z3barR1C
0000000000000000 W _ZN1C3fooEv
【问题讨论】:
-
能否发布您用于编译文件的命令行并发布
nm的输出?o found that bar is weakfoo弱,不是bar -
@KamilCuk,对不起,我把它们弄混了。
-
afaik weak 不是标准规定的;这是一个实现细节。