Click here to Skip to main content
15,914,500 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: SetWindowsHookEx question Pin
yonghengzhimi28-Apr-08 21:08
yonghengzhimi28-Apr-08 21:08 
GeneralRe: SetWindowsHookEx question Pin
Hamid_RT29-Apr-08 1:26
Hamid_RT29-Apr-08 1:26 
QuestionCan C++ code start a service Pin
Knowledgestudent27-Apr-08 11:10
Knowledgestudent27-Apr-08 11:10 
GeneralRe: Can C++ code start a service Pin
Charles Spirz27-Apr-08 12:02
Charles Spirz27-Apr-08 12:02 
QuestionRe: Can C++ code start a service Pin
Knowledgestudent27-Apr-08 13:48
Knowledgestudent27-Apr-08 13:48 
GeneralRe: Can C++ code start a service Pin
Charles Spirz27-Apr-08 14:35
Charles Spirz27-Apr-08 14:35 
AnswerRe: Can C++ code start a service Pin
ThatsAlok1-Jul-09 0:04
ThatsAlok1-Jul-09 0:04 
QuestionFunction pointers from DLL [modified] Pin
Michael Siroen27-Apr-08 10:08
Michael Siroen27-Apr-08 10:08 
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:
<br />
on_a = function_to_do_on_A;<br />
on_esc = function_to_do_on_Esc;<br />

where on_a comes from the dll and the function_to_do_on_A comes from the application.

this is my code:
<br />
Dll:<br />
.h<br />
#define ENGINE_EXPORTS<br />
#ifdef ENGINE_EXPORTS<br />
#define ENGINE_API __declspec(dllexport)<br />
#else<br />
#define ENGINE_API __declspec(dllimport)<br />
#endif<br />
<br />
.cpp<br />
namespace Engine<br />
{<br />
	namespace Input<br />
	{<br />
		ENGINE_API void (*on_a)(void);<br />
		ENGINE_API void (*on_b)(void);<br />
		ENGINE_API void (*on_c)(void);<br />
	}<br />
}<br />
<br />
<br />
Exe:<br />
.cpp<br />
void FuncA(void)<br />
{<br />
	MessageBox(NULL, L"FuncA called!", L"NOTIFICATION!", MB_OK);<br />
	return;<br />
}<br />
<br />
int main()<br />
{<br />
	Engine::Input::on_a = &FuncA;<br />
	return 0;<br />
}<br />
<br />
errors<br />
on_a is not a member of Engine::Input<br />
on_a undeclared identifier<br />
<br />
<br />
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-<br />
Exe:<br />
.cpp<br />
int main()<br />
{<br />
	{<br />
		using namespace Engine::Input;<br />
		on_a = &FuncA;<br />
	}<br />
	return 0;<br />
}<br />
<br />
errors<br />
on_a undeclared identifier<br />
<br />
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-<br />
<br />
.h<br />
namespace Engine<br />
{<br />
	namespace Input<br />
	{<br />
		extern ENGINE_API void(*on_a)(void);<br />
	}<br />
}<br />
<br />
error LNK2001: unresolved external symbol "void (__cdecl* Engine::Input::on_a)(void)" (?on_a@Input@Engine@@3P6AXXZA)<br />


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 VS2008

modified on Sunday, April 27, 2008 4:19 PM

GeneralRe: Function pointers from DLL Pin
Mark Salsbery27-Apr-08 10:56
Mark Salsbery27-Apr-08 10:56 
GeneralRe: Function pointers from DLL Pin
Michael Siroen27-Apr-08 10:58
Michael Siroen27-Apr-08 10:58 
GeneralRe: Function pointers from DLL Pin
Mark Salsbery27-Apr-08 11:28
Mark Salsbery27-Apr-08 11:28 
GeneralRe: Function pointers from DLL Pin
Michael Siroen27-Apr-08 11:40
Michael Siroen27-Apr-08 11:40 
GeneralRe: Function pointers from DLL Pin
Ozer Karaagac27-Apr-08 11:36
professionalOzer Karaagac27-Apr-08 11:36 
GeneralRe: Function pointers from DLL [modified] Pin
Michael Siroen27-Apr-08 11:51
Michael Siroen27-Apr-08 11:51 
GeneralGet time of system Pin
phap27-Apr-08 8:31
phap27-Apr-08 8:31 
GeneralRe: Get time of system Pin
Saurabh.Garg27-Apr-08 9:10
Saurabh.Garg27-Apr-08 9:10 
GeneralRe: Get time of system Pin
Hamid_RT29-Apr-08 1:25
Hamid_RT29-Apr-08 1:25 
Generalhelp please Pin
rasred27-Apr-08 8:23
rasred27-Apr-08 8:23 
GeneralCStdio exception handler Pin
Member 330122927-Apr-08 4:20
Member 330122927-Apr-08 4:20 
GeneralRe: CStdio exception handler Pin
Jijo.Raj27-Apr-08 6:22
Jijo.Raj27-Apr-08 6:22 
GeneralRe: CStdio exception handler Pin
Randor 27-Apr-08 10:28
professional Randor 27-Apr-08 10:28 
Questionunicode const string must be like: L"abc"? Pin
followait26-Apr-08 23:26
followait26-Apr-08 23:26 
AnswerRe: unicode const string must be like: L"abc"? Pin
CPallini27-Apr-08 4:34
mveCPallini27-Apr-08 4:34 
AnswerRe: unicode const string must be like: L"abc"? Pin
Mark Salsbery27-Apr-08 8:04
Mark Salsbery27-Apr-08 8:04 
GeneralRe: unicode const string must be like: L"abc"? Pin
followait27-Apr-08 19:48
followait27-Apr-08 19:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.