更新时间:2022-12-08 15:18:31
的externC
用来确保下列符号不是的错位(饰)
extern "C"
is used to ensure that the symbols following are not mangled (decorated).
示例:
让我们说我们有一个文件名为以下code TEST.CPP
:
Let's say we have the following code in a file called test.cpp
:
extern "C" {
int foo() {
return 1;
}
}
int bar() {
return 1;
}
如果您运行 GCC -c TEST.CPP -o test.o
在符号名请看下图:
00000010牛逼_Z3barv
00000010 T _Z3barv
00000000牛逼富
00000000 T foo
富()
保留其名称。