“Somefunction”的多个定义,DLLMain @ 12的多个定义

时间:2018-03-19 13:09:54

标签: c++

我正在编写一个DLL来显示MessageBoxA的{​​{1}}函数。

我不断收到错误

  1. 'SomeFunction'的多个定义
  2. 'DLLMain @ 12'的多重定义
  3. 首先在此定义
  4. 通过阅读某些解决方案并比较我拥有的文件,user32.dllmain.h具有重复的功能main.cpp。我该如何纠正? SomeFunction在头文件ifndef中定义。我尝试添加内联语法,但这不起作用。

    main.h

    main.cpp

    #include "main.h" // a sample exported function void DLL_EXPORT SomeFunction(const LPCSTR sometext) { MessageBoxA(0, sometext, "DLL Message", MB_OK | MB_ICONINFORMATION); } extern "C" DLL_EXPORT BOOL APIENTRY 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; } return TRUE; // succesful }

    main.c

    #include <windows.h> #include <stdio.h> #include <stdlib.h> #include <main.h> void Test(void) { MessageBoxA( NULL, "test", "", 0); }

    main.h

0 个答案:

没有答案
相关问题