C++ C++;:警告:dll链接不一致

C++ C++;:警告:dll链接不一致,c++,dll,visual-studio-2015,C++,Dll,Visual Studio 2015,我对Visual studio(在C++中)有问题 我得到一个警告,我不知道为什么,因为我从来没有调用2次相同的变量 函数:dll链接不一致 警告列表:(法语) 我读过微软:但我不知道这是否是我的问题,因为这个例子和我的不一样 我也读了,它告诉我,因为我在dll中使用MFC,但我没有检查MFC头。 这是我的“Pay.h” #pragma一次 #ifdef PayretteDLL_导出 #定义付款方式DLL\U API\U declspec(dllexport) #否则 #定义付款方式API

我对Visual studio(在C++中)有问题

我得到一个警告,我不知道为什么,因为我从来没有调用2次相同的变量

函数:dll链接不一致

警告列表:(法语)

我读过微软:但我不知道这是否是我的问题,因为这个例子和我的不一样

我也读了,它告诉我,因为我在dll中使用MFC,但我没有检查MFC头。

这是我的“Pay.h”

#pragma一次
#ifdef PayretteDLL_导出
#定义付款方式DLL\U API\U declspec(dllexport)
#否则
#定义付款方式API declspec(dllimport)
#恩迪夫
#包括
#包括
#包括
命名空间DLL
{
阶级尊重
{
私人:
静态结构std::tm时;
公众:
静态payrettdll_API bool是_setup();
静态PayDll_API无效设置(标准::字符串日期);
静态payrettdll_API bool_可能();
}
}
PayDll.cpp:

// PayRespectDLL.cpp :
//

#include "stdafx.h"
#include "PayRespectDLL.h"
#include <stdexcept>
#include <time.h>
#include <string>
#include <stdlib.h>


using namespace std;

namespace PayRespectdll
{
    bool PayRespect::is_setup()
    {
        return false;//already_setup;
    }

    // setup attempt String: hh:mm:ss.
    void PayRespect::setup(string date)
    {
        return;
    }

    bool PayRespect::is_possible()
    {
        return true;
    }
}
//payrettdll.cpp:
//
#包括“stdafx.h”
#包括“PayDll.h”
#包括
#包括
#包括
#包括
使用名称空间std;
命名空间DLL
{
bool Pay尊敬::是安装程序()
{
返回false;//已经安装了\u;
}
//设置尝试字符串:hh:mm:ss。
void Pay尊重::设置(字符串日期)
{
返回;
}
boolpayrespect::可能吗()
{
返回true;
}
}

谢谢大家!

如果您使用的是MFC,我曾经有过编译错误(“不一致的DLL链接”),因为我在头文件中定义了一个方法体,而该方法不是“内联”的。

当编译器解析声明并看到_declspec(dllimport)时,您将收到此警告。但随后也看到了函数的定义。这不可能是正确的,当然,它不能从另一个DLL导入,也不能由您的代码实现。发生这种情况最明显的原因是,当我从另一个应用程序调用我的dll时,您忘记定义或拼写错误了PayRespect dll\u Exports。。我只需要加上“.h”。。。没有定义什么?我遵循一个创建dll的教程,我想它从来没有看到我需要在我的解决方案中定义一些东西。你能给我一个正确定义它的教程吗?右键单击你的DLL项目>属性>C/C++>预处理器>预处理器定义设置。添加PayU导出。对所有其他配置重复上述步骤。这应该是可以发现的,再花一个小时四处看看。当您不懂某些内容时,请按F1。
// PayRespectDLL.cpp :
//

#include "stdafx.h"
#include "PayRespectDLL.h"
#include <stdexcept>
#include <time.h>
#include <string>
#include <stdlib.h>


using namespace std;

namespace PayRespectdll
{
    bool PayRespect::is_setup()
    {
        return false;//already_setup;
    }

    // setup attempt String: hh:mm:ss.
    void PayRespect::setup(string date)
    {
        return;
    }

    bool PayRespect::is_possible()
    {
        return true;
    }
}