Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 是否为g++;将C标准库的名称声明为extern“;";链接或外部“;C++&引用;?_C++_G++ - Fatal编程技术网

C++ 是否为g++;将C标准库的名称声明为extern“;";链接或外部“;C++&引用;?

C++ 是否为g++;将C标准库的名称声明为extern“;";链接或外部“;C++&引用;?,c++,g++,C++,G++,根据ISO_14882_2014第[17.6.2]节 Whether a name from the C standard library declared with external linkage has extern "C" or extern "C++" linkage is implementation-defined. It is recommended that an implementation use extern "C++" linkage for this purpose

根据ISO_14882_2014第[17.6.2]节

Whether a name from the C standard library declared with external linkage has
extern "C" or extern "C++" linkage is implementation-defined. It is 
recommended that an implementation use extern "C++" linkage for this purpose.
因为这是一个实现定义的行为,所以我正在查看g++文档,但没有任何内容


对于C标准库函数,g++有什么链接?我检查了名称是否因任何函数而损坏。。发现它不是。那么这是否意味着g++具有外部“C”链接?

这取决于您使用的标准库,而不是编译器

典型地,使用<代码> G++< /C> >将使用<代码> LBSTDC++< /COD>,即GNU C++库(这又依赖于<代码> GLUBC/<代码>,即GNU C库)。默认情况下,这一个似乎使用C链接作为C名称。如果您查看源代码本身,您将看到可能使用的4组不同的C头文件

在任何情况下,您都不应该依赖它,它也可能在没有警告的情况下更改,即使在发布之间也是如此

理想情况下,如果出于某种原因(无论是否损坏)需要导出的名称,应该直接从共享对象或编译器正在使用的头中获取它,而不是依赖于给定的链接


尽管如此,主要的标准库/编译器还是以
extern“C”
的形式提供它们,甚至在Windows上提供MSVC;即使使用C++ <代码> cNeN/COD>标头(当然是全局命名空间中的标题)。这比我问的更能回答问题。