Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I am trying to implement a Callback function that would return an Array of pointers. Here is my code, but I keep getting an error message. Does anyone know the correct syntax for a callback function that returns an array of pointers?
code:
//The original array is here:
__declspec(dllexport) bot_movestate_t *botmovestates[MAX_CLIENTS+1];
__declspec(dllexport) struct bot_movestate_s **Getbotmovestates( void )
{
	return botmovestates;
}


struct bot_movestate_s *ai_main_botmovestates[MAX_CLIENTS+1];
typedef struct bot_movestate_s **(* fGetbotmovestates_t)( void );
struct bot_movestate_s **fGetbotmovestates( fGetbotmovestates_t pfGetbotmovestates ){
	return pfGetbotmovestates();
}

//sm func
void smfunc()
{
	fGetbotmovestates_t pfGetbotmovestates;
	HMODULE hLib;
	
/////////////////////////////

	hLib = LoadLibrary(TEXT("smdll.dll"));
		if (hLib == NULL) {
		//Module not found, permission denied, ...
		return; //inform caller of error
	}

	pfGetbotmovestates = (fGetbotmovestates_t)GetProcAddress(hLib, TEXT("Getbotmovestates"));
	if ( pfGetbotmovestates == NULL) {
		return;
	}

	ai_main_botmovestates = fGetbotmovestates(pfGetbotmovestates);//error C2106: '=' : left operand must be l-value

/////////////////////////////

}


//error
error C2106: '=' : left operand must be l-value
Posted
Updated 16-Dec-11 18:21pm
v3
Comments
Amir Mahfoozi 17-Dec-11 6:12am    
You can return a simple "void *" or even a DWORD data type from your DLL and cast it to whatever you want in the application.

1 solution

You have defined ai_main_botmovestates as an array of pointers rather than a pointer, so you cannot assign anything to it without using an index. Change its declaration to:
C++
struct bot_movestate_s **ai_main_botmovestates;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900