如何编写获取指针数组的Callback函数? [英] How do I write a Callback function that gets an array of pointers?

查看:89
本文介绍了如何编写获取指针数组的Callback函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试实现一个回调函数,该函数将返回一个指针数组.这是我的代码,但我不断收到错误消息.有谁知道返回指针数组的回调函数的正确语法?
代码:

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

推荐答案

您已将ai_main_botmovestates定义为指针数组而不是指针,因此如果不使用索引就无法为其分配任何内容.将其声明更改为:
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:
struct bot_movestate_s **ai_main_botmovestates;


这篇关于如何编写获取指针数组的Callback函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆