0
我創建了一個名爲測試庫DLL中的項目:功能被錯誤地標記爲dllimport
// main.h
#ifndef __MAIN_H__
#define __MAIN_H__
#ifdef BUILD_DLL
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT __declspec(dllimport)
#endif
extern "C" {
DLL_EXPORT void print();
}
#endif
// main.cpp
#include "main.h"
#include <iostream>
#define BUILD_DLL
using std::cout;
using std::endl;
extern "C" {
DLL_EXPORT void print() {
cout << "Success" << endl;
return;
}
}
上面的代碼是從下面我在網上找到,我可以理解一個例子。當我嘗試編譯和/或構建它,我收到以下錯誤&警告:
error: function 'void print()' definition is marked dllimport
In function 'void print()':
warning: 'void print()' redeclared without dllimport attribute: previous dllimport ignored
這是我曾經創造,因爲我想在第一個複製問題的第二個庫,當這發生。哪裏不對?我使用的是Code :: Blocks。