`
dawning126
  • 浏览: 46369 次
  • 性别: 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文件引用删除即可。
分享到:
评论

相关推荐

    Google C++ International Standard.pdf

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

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

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

    西门子_CE DECLARATION of CONFORMITY.pdf

    标题中提到的“西门子_CE DECLARATION of CONFORMITY.pdf”指的是西门子公司为某产品家族出具的符合性声明文件(CE Declaration of Conformity),这份文件表明了该产品家族符合欧洲共同体的相关指令,并且已经通过...

    Addison.Wesley.C++.by.Dissection.2002.pdf

    Based on the provided information from the file "Addison.Wesley.C++.by.Dissection.2002.pdf," we can derive a comprehensive overview of the C++ programming language as covered in this text. The book is...

    ESWA的Declaration of Interest statement(利益声明)word版

    "ESWA的Declaration of Interest statement(利益声明)word版"是一个重要的文件,它涉及到作者在发表论文时必须公开的任何可能影响其研究成果公正性的财务或个人关系。这份声明通常会伴随论文一同发布,以确保读者...

    C++常用英语单词.pdf

    在C++编程语言中,理解和掌握这些常用英语单词是至关重要的,因为它们构成了C++语法、概念和技术的基础。下面是对这些词汇的详细解释: 1. **抽象数据类型(abstract data type, ADT)**:ADT是一种数据结构,它定义...

    c++专业英语单词.docx

    在C++编程语言中,理解和掌握相关的专业英语词汇是至关重要的。以下是一些C++中的核心概念和术语: 1. **Operator**:操作符,如算术运算符(arithmetic operators)如`+`, `-`, `*`, `/`, `%`,赋值运算符...

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

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

    Problem Solving with C++ (7th edition)

    ### Problem Solving with C++ (7th Edition) #### Chapter 1: Compiling and Running a C++ Program In this chapter, the focus is on understanding the process of creating a C++ program from start to ...

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

    Declaration of academic integrity form

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

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

    SqList_Declaration.h

    SqList_Declaration.h

    google c++代码规范

    Google C++ 编程规范 目录 一、头文件........................................................................................................................................4 1. #define的保护..............

    C++中枚举类型(enum)

    ### C++中的枚举类型(Enum) 在C++编程语言中,枚举(`enum`)是一种用户定义的类型,它由一组具有整数值的命名常量组成。这些值可以被程序用来代替数字,使代码更具可读性,并且能够表示特定范围内的固定集合。 ...

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

    c++错误解释(比较常见的错误类型)

    在C++中,如果函数调用时没有函数的说明,会出现call to function with no prototype错误。在函数调用时,需要确保函数已经定义并提供了正确的函数说明。 Cannot modify a const object(不允许修改常量对象) ----...

    SystemVerilog for Design(2nd edition)

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

    安卓游戏2048

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

Global site tag (gtag.js) - Google Analytics