My dll is exporting every function without my consent!

I am using a mingw compiler and code blocks IDE. I am facing a problem in which I don't understand how come my dll exports every function without me even using `__declspec(dllexport)` with these functions. Here are the two sample files, `main.h` and `main.cpp`: `main.h`: #ifndef __MAIN_H__ #define __MAIN_H__ #include windows.h #ifdef BUILD_DLL #define DLL_EXPORT __declspec(dllexport) #else #define DLL_EXPORT __declspec(dllimport) #endif #ifdef __cplusplus extern "C" { #endif void SomeFunction(const LPCSTR sometext); #ifdef __cplusplus } #endif #endif // __MAIN_H__ `main.cpp`: #include "main.h" void SomeFunction(const LPCSTR sometext) { MessageBoxA(0, sometext, "DLL fxn Message", MB_OK | MB_ICONINFORMATION); } bool flag = false; extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH: // attach to process // return FALSE to fail DLL load break; case DLL_PROCESS_DETACH: // detach from process break; case DLL_THREAD_ATTACH: // attach to thread break; case DLL_THREAD_DETACH: // detach from thread break; } flag = true; return TRUE; // succesful } In this example, `SomeFunction` is exported and I am able to dynamically call it from an application externally, although I haven't prototyped it as void __declspec(dllexport) SomeFunction(const LPSTR sometext); Not only this, even the global variable `flag` is exported in the auto generated .def file. What is happening here? Please help and correct me if I am making a technical mistake.
possible duplicate of How to tell the MinGW linker not to export all symbols?

以上就是My dll is exporting every function without my consent!的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准