[英]'AddIntImpl': inconsistent dll linkage : while creating dll using empty project option in visual studio
最小的可重現示例:
在創建項目時,我在菜單中選擇了空項目。 創建項目后,我確實將配置類型更改為 dll。
在此之后,我創建了兩個文件,Calculations.h 和 cpp
兩個文件的內容:
計算.h
#pragma once
#ifdef CALCULATIONS_EXPORTS
#define CALCULATIONS_API __declspec(dllexport)
#else
#define CALCULATIONS_API __declspec(dllimport)
#endif
CALCULATIONS_API int AddIntImpl(int a, int b);
計算.cpp
#include "Calculations.h"
int AddIntImpl(int a, int b)
{
return a + b;
}
現在在建造同樣的建築時,我得到了
1>Calculations.cpp
1>{...Path}\calculations.cpp(5): warning C4273: 'AddIntImpl': inconsistent dll linkage
1>{...Path}calculations.h(9): note: see previous definition of 'AddIntImpl'
我該如何解決?
一般來說,警告不會影響應用程序的運行。 因此,在編程時通常會忽略警告。
我建議你可以參考鏈接: https://stackoverflow.com/a/19932564/11872808
您可以嘗試以下方法來消除警告:
1->點擊項目->屬性->配置屬性->C/C++->高級->禁用特定警告,然后在文本框中添加4273。
2->在您的程序中添加以下語句:#pragma warning(disable:4273)。
3->關閉所有警告。 在屬性頁面中,打開 C/C++ 文件夾->常規->警告級別和 select“關閉所有警告 (/W0)”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.