在C++环境下使用C函数的时候,常常会出现编译器无法找到obj模块中的C函数定义,从而导致链接失败的情况,这是因为C++语言在编译的时候为了解决函数的多态问题,会将函数名和参数联合起来生成一个中间的函数名称,而C语言则不会,因此会造成链接时找不到对应函数的情况,此时C函数就需要用extern “C”进行链接指定,这告诉编译器,请保持我的名称,不要给我生成用于链接的中间函数名。
但有时还会出现
ms.h:29: error: previous declaration of 'int function(int)' with 'C++' linkage
main.cpp:24: error: conflicts with new declaration with 'C' linkage
这是因为在c++的文件中用extern定义过了函数,而又包含了该函数所在的.h文件头文件,只要把.h文件引用删除即可。
分享到:
相关推荐
The C++ Standard Library A Tutorial and Reference (2nd Edition)+cppstdlib-code.zip C++标准库(第二版)英文版.pdf 非扫描版+源代码 Prefaceto the SecondEdition xxiii Acknowledgments for the Second...
6.5 Program and linkage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 6.6 Start and termination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
西门子_CE DECLARATION of CONFORMITYpdf,
3.5 Program and linkage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 3.6 Start and termination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
Files contained in apt-mirror-api-0.1.jar: ...com.sun.mirror.declaration.ClassDeclaration.class com.sun.mirror.declaration.ConstructorDeclaration.class com.sun.mirror.declaration.Declaration.class ...
施耐德电气 Twido可编程控制器产品认证——CE Manufacturer’s Declaration TWDpdf,施耐德电气 Twido可编程控制器产品认证——CE Manufacturer’s Declaration TWD
RzBorder.pas Number of elements differs from declaration TRzLEDCharacters 在装完Raize控件之后编译老是出如下错误: [Pascal Error] RzBorder.pas(1429): E2072 Number of elements (125) differs from ...
of the script with intact names or some already recoved + manual improved with more meaningful function names. Bot files are shown side by side seperated by their functions Here some example: >...
requirement analysis •conceptual database design •choice of the DBMS •data model mapping •physical design •implementation
西门子_EG-Konformit�鋞serkl�鋜ung EC Declaration of Conformitypdf,
Note: If you use a symbol Foo in your source file, you should bring in a definition for Foo yourself, either via an #include or via a forward declaration. Do not depend on the symbol being brought in ...
SqList_Declaration.h
C++中枚举类型(enum)
import java.util.ArrayList; public class GameView extends GridLayout { private List<Point> emptyPoints=new ArrayList(); public GameView(Context context, AttributeSet attrs, int defStyle) { ...
/* Get size_t declaration. Get wchar_t declaration if it exists. */ #include <stddef.h> /* Get errno declaration and values. */ #include <errno.h> /* Some systems, like SunOS 4, don't have EILSEQ. ...
instant access to the Borland forums with their libraries of technical information and answers to common questions. If you are not a member of CompuServe, see the enclosed special offer, and ...
3.9.2. Interacting with C++....................................................................................45 PART 2—CORE CONSTRUCTS AND TECHNIQUES OF THE LANGUAGE Chapter 4—Basic constructs ...
3.9.2. Interacting with C++....................................................................................45 PART 2—CORE CONSTRUCTS AND TECHNIQUES OF THE LANGUAGE Chapter 4—Basic constructs ...
Chapter 2: SystemVerilog Declaration Spaces ........................................................7 2.1 Packages ........................................................................................
instant access to the Borland forums with their libraries of technical information and answers to common questions. If you are not a member of CompuServe, see the enclosed special offer, and ...