【发布时间】:2012-09-13 12:46:16
【问题描述】:
我正在尝试在 Visual Studio 中编译代码,但我不断收到以下错误:
错误 4 错误 C3867: 'MindSet::Form1::handleDataValueFunc': 函数调用缺少参数列表;使用 '&MindSet::Form1::handleDataValueFunc' 创建指向成员 c:\documents and settings\licap\desktop\mindset\mindset\mindset\Form1.h 的指针 122 1 MindSet
这是我的代码
#pragma endregion
void handleDataValueFunc(unsigned char extendedCodeLevel, unsigned char code,
unsigned char valueLength, const unsigned char *value, void *customData)
{
FILE *arq1;
FILE *arq2;
FILE *arq3;
arq1 = fopen("raw.txt","a");
arq2 = fopen("atencao.txt","a");
arq3 = fopen("meditacao.txt","a");
if (extendedCodeLevel == 0 && code == RAW_WAVE_CODE)
{
short rawValue = ((value[0] << 8) & 0xff00) | (0x00ff & value[1]);
printf("%d\n", rawValue);
fprintf(arq1,"%d\n",rawValue);
}
if (extendedCodeLevel == 0 && code == ATTENTION_LEVEL_CODE)
{
short attentionValue = (value[0] & 0xFF);
printf("%d\n", attentionValue);
fprintf(arq2,"%d\n",attentionValue);
}
if (extendedCodeLevel == 0 && code == MEDITATION_LEVEL_CODE)
{
short meditationValue = (value[0] & 0xFF);
printf("%d\n", meditationValue);
fprintf(arq3,"%d\n",meditationValue);
}
fclose(arq1);
fclose(arq2);
fclose(arq3);
}
private: System::Void IniciarCaptura_Click(System::Object^ sender, System::EventArgs^ e) {
SerialPort* port = new SerialPortW32();
if (port->open())
{
/* Initialize ThinkGear stream parser */
ThinkGearStreamParser parser;
THINKGEAR_initParser(&parser, PARSER_TYPE_PACKETS, handleDataValueFunc, NULL);
unsigned char byteRead;
for (int i = 0; i < 100000; i++)
{
if (port->read(&byteRead, 1) == 1)
{
THINKGEAR_parseByte(&parser, byteRead);
fflush(stdout);
}
else
{
//cerr << "Erro na leitura da porta" << endl;
break;
}
}
port->close();
}
else
{
//cout << port->getErrorMessage() << endl;
}
delete port;
//return 0;
}
};
}
我已经尝试在“handleDataValueFunc”之前添加一个“&”,但它只返回另一个错误消息。有人可以帮忙吗?
【问题讨论】:
-
其他错误信息是什么?你在哪一行得到错误?
-
这是一个函数定义。它在哪里使用。我假设您将它作为回调传递给其他地方。
-
THINKGEAR_initParser是您的代码吗?你能分享它的代码吗? -
该错误明确表示“使用'&MindSet::Form1::handleDataValueFunc'”而不是“使用'&handleDataValueFunc”。
-
我想
handleDataValueFunc实际上是一个成员函数,对吧? THINKGEAR_initParser 是否有可能采用普通函数指针?您不能用成员函数指针替换它,因为它不是一回事(实际上成员 fn ptr 根本不是真正的指针)。尝试将handleDataValueFunc移出课堂。
标签: visual-studio-2010 c++-cli function-pointers function-call