Never, I just got this one (since december last year) so I never really changed. But then again I'm just 20 :)
Michael Siroen
Posts
-
How many times have you changed jobs ... -
Function pointers from DLL [modified]thanks, that already helped a lot.. (the DllCpp was the problem, #define over there instead above the header..) Since multiple header files all include this one (Engine.h), I get several (7) Errors Error LNK2005: "void (__cdecl* Engine::Input::on_a)(void)" (?on_a@Input@Engine@@3P6AXXZA) already defined in Engine.obj LuaScriptor.obj But I think I can get around that problem, or just by simply putting everything inside a single header and source file. Thanks to all for the support and the quick help :) EDIT: Fixed all (Copy everything to Engine.cpp and Engine.h), thanks
modified on Sunday, April 27, 2008 6:10 PM
-
Function pointers from DLL [modified]The namespace Engine and it's 'member'- namespace Input are within the Dll file.. This means that the declaration is within the Dll file: ENGINE_API void (*on_a)(void); if I put the following code above the main function of mine: namespace Engine { namespace Input { __declspec(dllimport) void (*on_a)(void); }} I get the following warning: warning C4273: 'Engine::Input::on_a' : inconsistent dll linkage followed up with an error: error C3861: 'on_a': identifier not found
-
Function pointers from DLL [modified]yes as follows..
#include "..\Engine\Engine.h" #if defined(DEBUG) | defined(_DEBUG) #define USE_DEBUG_ENGINE #endif #ifdef USE_DEBUG_ENGINE #pragma comment(lib, "..\\Debug\\Engine.lib") #else #pragma comment(lib, "..\\Release\\Engine.lib") #endif
normal functions (and classes) declared within the namespace are working properly for instance:int Height = Engine::GetHeight();
returns the proper value -
Function pointers from DLL [modified]I was busy creating a Dll for some basic game engine (just for myself) For the input, I would like to have some general function pointers inside my dll which I want to be able to reference to other functions from code based upon my exe file. just like this:
on_a = function_to_do_on_A; on_esc = function_to_do_on_Esc;
where on_a comes from the dll and the function_to_do_on_A comes from the application. this is my code:Dll: .h #define ENGINE_EXPORTS #ifdef ENGINE_EXPORTS #define ENGINE_API __declspec(dllexport) #else #define ENGINE_API __declspec(dllimport) #endif .cpp namespace Engine { namespace Input { ENGINE_API void (*on_a)(void); ENGINE_API void (*on_b)(void); ENGINE_API void (*on_c)(void); } } Exe: .cpp void FuncA(void) { MessageBox(NULL, L"FuncA called!", L"NOTIFICATION!", MB_OK); return; } int main() { Engine::Input::on_a = &FuncA; return 0; } errors on_a is not a member of Engine::Input on_a undeclared identifier -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Exe: .cpp int main() { { using namespace Engine::Input; on_a = &FuncA; } return 0; } errors on_a undeclared identifier -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- .h namespace Engine { namespace Input { extern ENGINE_API void(*on_a)(void); } } error LNK2001: unresolved external symbol "void (__cdecl* Engine::Input::on_a)(void)" (?on_a@Input@Engine@@3P6AXXZA)
What am I doing wrong? Why is my function pointer not being exported? And how to fix this problem? Many thanks in advance. ps. I am using VS2008modified on Sunday, April 27, 2008 4:19 PM