【问题标题】:error C2732: linkage specification contradicts earlier specification for 'log'错误 C2732:链接规范与“日志”的早期规范相矛盾
【发布时间】:2015-07-29 06:00:00
【问题描述】:

我写了一些函数,并把它编译成一个dll模块。在我的头文件中如下:

#ifndef GET_DATAFEED_FORKDB_H
#define GET_DATAFEED_FORKDB_H

#include "..\include\stdafx.h"
#include <windows.h>

#include "..\include\TDFAPI.h"
#include "..\include\TDFAPIStruct.h"
#include "..\include\PathHelper.h"
#include "..\include\ConfigSettings.h"

// some helper functions
// ....

extern "C" void openConnect();
extern "C" void closeConnect();

#endif 

但是,当我使用 Visual Studio 2013 Professional 编译它时,我遇到了一些错误:

F:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(501) :
  error C2732: linkage specification contradicts earlier specification for  'log'
F:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(501) : 
 see declaration of 'log'
F:\Program Files (x86)\Microsoft Visual Studio12.0\VC\INCLUDE\xtgmath.h(104)
  :error C2732: linkage specification 
  contradicts earlier specification for 'log'
F:\Program Files (x86)\Microsoft Visual Studio12.0\VC\INCLUDE\xtgmath.h(104)
  : see declaration of 'log'
F:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\xlocale(337)
  : warning C4530: C++ exception handler used, but unwind semantics are not 
   enabled. Specify /EHsc

我没有使用数学方法。所以我尝试使用this method来解决它,但它没有奏效。包含的头文件不能不修改,我也试过用这个方法:

 extern "C" {
    #include "..\include\TDFAPI.h"
    #include "..\include\TDFAPIStruct.h"
    #include "..\include\k.h"
    #include "..\include\PathHelper.h"
    #include "..\include\ConfigSettings.h"
  }

,更糟糕的是,它发生了更多的错误。

【问题讨论】:

  • 如果您不使用数学库,为什么还需要标头?
  • @cremno,我没有调用任何数学函数,并定义了名为 log 的数学函数。
  • @SouravGhosh,我没有包含数学头文件。但是在我的头文件中,我声明了一些这样的函数:extern "C" void openConnect(); extern "C" void closeConnect();
  • 那你需要发一个MCVE,去掉C标签。
  • @cremno,谢谢你的建议。

标签: c++ dll visual-studio-2013


【解决方案1】:

我刚遇到和你一样的问题。我遇到了和你一样的问题。 #include "k.h" 必须放在包含任何标准头之后。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-07
    • 2014-10-12
    • 1970-01-01
    • 2023-03-25
    • 1970-01-01
    • 2012-04-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多