C语言缺少参数,c – 函数调用缺少参数列表以创建指针
发布日期:2021-10-27 11:20:54 浏览次数:9 分类:技术文章

本文共 2662 字,大约阅读时间需要 8 分钟。

我试图通过VRPN服务器将我的应用程序连接到OpenViBE.我的应用程序运行良好,直到我尝试添加代码将我的应用程序连接到VRPN服务器.

我的代码看起来像这样:

MainWindow.c代码:

#include "mainwindow.h"

#include "ui_mainwindow.h"

#include

#include

#include

#include

#include

using namespace std;

#include "vrpn_Analog.h"

MainWindow::MainWindow(QWidget *parent) :

QMainWindow(parent),

ui(new Ui::MainWindow)

{

ui->setupUi(this);

currentImage = 0;

labelSize = ui->label_2->size();

createActions();

openFileDialog();

}

void MainWindow::checkChannels()

{

vrpn_Analog_Remote *vrpnAnalog = new vrpn_Analog_Remote("Mouse0@localhost");

vrpnAnalog->register_change_handler( 0, handle_analog );

}

void VRPN_CALLBACK MainWindow::handle_analog( void* userData, const vrpn_ANALOGCB a )

{

int nbChannels = a.num_channel;

cout << "Analog : ";

for( int i=0; i < a.num_channel; i++ )

{

cout << a.channel[i] << " ";

}

cout << endl;

}

MainWindow.h代码:

#ifndef MAINWINDOW_H

#define MAINWINDOW_H

#include

#include

#include "vrpn_Analog.h"

namespace Ui {

class MainWindow;

}

class MainWindow : public QMainWindow

{

Q_OBJECT

public:

explicit MainWindow(QWidget *parent = 0);

~MainWindow();

protected:

void resizeEvent(QResizeEvent *);

private slots:

void openFileDialog();

private:

void checkChannels();

void VRPN_CALLBACK handle_analog( void* userData, const vrpn_ANALOGCB a );

};

#endif // MAINWINDOW_H

使用此代码,当我尝试运行我的应用程序时,我得到:

error: C3867: 'MainWindow::handle_analog': function call missing argument list; use '&MainWindow::handle_analog' to create a pointer to member

我尝试通过错误建议编辑代码,但我收到另一个错误:

error: C2664: 'vrpn_Analog_Remote::register_change_handler' : cannot convert parameter 2 from 'void (__stdcall MainWindow::* )(void *,const vrpn_ANALOGCB)' to 'vrpn_ANALOGCHANGEHANDLER'

There is no context in which this conversion is possible

我四处搜索,但我找不到任何可用的解决方案.

方法checkChannels和handle_analog我从这段代码“复制”,一切正常:

#include

#include

#include "vrpn_Analog.h"

void VRPN_CALLBACK vrpn_analog_callback(void* user_data, vrpn_ANALOGCB analog)

{

for (int i = 0; i < analog.num_channel; i++)

{

if (analog.channel[i] > 0)

{

std::cout << "Analog Channel : " << i << " / Analog Value : " << analog.channel[i] << std::endl;

}

}

}

int main(int argc, char *argv[])

{

QCoreApplication a(argc, argv);

/* flag used to stop the program execution */

bool running = true;

/* VRPN Analog object */

vrpn_Analog_Remote* VRPNAnalog;

/* Binding of the VRPN Analog to a callback */

VRPNAnalog = new vrpn_Analog_Remote("openvibe_vrpn_analog@localhost");

VRPNAnalog->register_change_handler(NULL, vrpn_analog_callback);

/* The main loop of the program, each VRPN object must be called in order to process data */

while (running)

{

VRPNAnalog->mainloop();

}

return 0;

return a.exec();

}

我在哪里做错了?感谢所有回复.

转载地址:https://blog.csdn.net/weixin_34518190/article/details/117070426 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:C语言设计A与B的区别,C语言辅导 - a>b>c与a=b=c的区别 and something else
下一篇:自学c语言看视频怎么好晕呀,C语言指针学多了,你为什么会觉得晕?

发表评论

最新留言

逛到本站,mark一下
[***.202.152.39]2024年03月28日 08时40分17秒