求动态链接库中预编译错误的解决方法
在动态链接库中这样声明后在编译时有预编译错误。
请教那里有问题?
这是错误信息
[BCC32 Warning] System.DateUtils.hpp(132): W8058 Cannot create pre-compiled header: initialized data in header
动态链接库中的声明部分
test.dll
#include <vcl.h>
#include <windows.h>
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <IdAntiFreezeBase.hpp>
#include <IdBaseComponent.hpp>
#include <IdComponent.hpp>
#include <IdConnectThroughHttpProxy.hpp>
#include <IdCustomTransparentProxy.hpp>
#include <IdIOHandler.hpp>
#include <IdIOHandlerSocket.hpp>
#include <IdIOHandlerStack.hpp>
#include <IdSocks.hpp>
#include <IdTCPClient.hpp>
#include <IdTCPConnection.hpp>
#include <Vcl.ComCtrls.hpp>
#include <Vcl.IdAntiFreeze.hpp>
#include <Vcl.ExtCtrls.hpp>
#include <DateUtils.hpp>
#pragma hdrstop
extern "C" __declspec(dllexport) void __stdcall InitionWithProgress(TProgressBar *,UnicodeString ,UnicodeString);
extern "C" __declspec(dllexport) void __stdcall UploadFileWithProgress(UnicodeString, UnicodeString,UnicodeString &,bool &);
extern "C" __declspec(dllexport) void __stdcall DestroyWithProgress(void);
extern "C" __declspec(dllexport) void __stdcall setInitionTransfer(UnicodeString,UnicodeString);
extern "C" __declspec(dllexport) void __stdcall StartUploadFile(UnicodeString, UnicodeString,UnicodeString &,bool &);
extern "C" __declspec(dllexport) void __stdcall setDestroyTransfer(void);
extern "C" __declspec(dllexport) int __stdcall MyTest(int,int);
#pragma argsused
TIdTCPClient *UploadClient;
TIdIOHandlerStack *IdIOHandlerStack1;
TIdAntiFreeze *IdAntiFreeze1;
TIdConnectThroughHttpProxy *IdConnectThroughHttpProxy1;
TIdSocksInfo *IdSocksInfo1;
UnicodeString srvPort,srvIP;
TProgressBar *ProgressBar1;
//-----------------------------------------
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
[解决办法]
重点是#pragma hdrstop这一句的位置,默认是紧跟在#include <vcl.h>后面,如果在#pragma hdrstop之前还有更多的包含文件,你需要保证工程中每个单元都是这样的顺序,如果你不太了解,建议不要随便更改这两句:
#include <vcl.h>
#pragma hdrstop