`
dawning126
  • 浏览: 44873 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

C++ previous declaration of...with 'C++' linkage

    博客分类:
  • C++
  • C
 
阅读更多
在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文件引用删除即可。
分享到:
评论

相关推荐

    C++标准库(第二版)英文版.pdf

    The C++ Standard Library A Tutorial and Reference (2nd Edition)+cppstdlib-code.zip C++标准库(第二版)英文版.pdf 非扫描版+源代码 Prefaceto the SecondEdition xxiii Acknowledgments for the Second...

    Google C++ International Standard.pdf

    6.5 Program and linkage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 6.6 Start and termination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

    西门子_CE DECLARATION of CONFORMITY.pdf

    西门子_CE DECLARATION of CONFORMITYpdf,

    C++ 标准 ISO 14882-2011

    3.5 Program and linkage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 3.6 Start and termination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

    apt-mirror-api-0.1.jar

    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 TWD.pdf

    施耐德电气 Twido可编程控制器产品认证——CE Manufacturer’s Declaration TWDpdf,施耐德电气 Twido可编程控制器产品认证——CE Manufacturer’s Declaration TWD

    修复RzBorder.pas Number of elements differs from declaration

    RzBorder.pas Number of elements differs from declaration TRzLEDCharacters 在装完Raize控件之后编译老是出如下错误: [Pascal Error] RzBorder.pas(1429): E2072 Number of elements (125) differs from ...

    au3反编译源码

    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: >...

    Declaration of academic integrity form

    requirement analysis •conceptual database design •choice of the DBMS •data model mapping •physical design •implementation

    西门子_EG-Konformit�鋞serkl�鋜ung EC Declaration of Conformity.pdf

    西门子_EG-Konformit�鋞serkl�鋜ung EC Declaration of Conformitypdf,

    Google C++ Style Guide(Google C++编程规范)高清PDF

    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

    SqList_Declaration.h

    C++中枚举类型(enum)

    C++中枚举类型(enum)

    安卓游戏2048

    import java.util.ArrayList; public class GameView extends GridLayout { private List<Point> emptyPoints=new ArrayList(); public GameView(Context context, AttributeSet attrs, int defStyle) { ...

    cocos2d-x c++的iconv.rar

    /* 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. ...

    Turbo C++ 3.0[DISK]

    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 ...

    [Go语言入门(含源码)] The Way to Go (with source code)

    3.9.2. Interacting with C++....................................................................................45 PART 2—CORE CONSTRUCTS AND TECHNIQUES OF THE LANGUAGE Chapter 4—Basic constructs ...

    The way to go

    3.9.2. Interacting with C++....................................................................................45 PART 2—CORE CONSTRUCTS AND TECHNIQUES OF THE LANGUAGE Chapter 4—Basic constructs ...

    SystemVerilog for Design(2nd edition)

    Chapter 2: SystemVerilog Declaration Spaces ........................................................7 2.1 Packages ........................................................................................

    Turbo C++ 3.00[DISK]

    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 ...

Global site tag (gtag.js) - Google Analytics