有什么我没看到的吗?
我的项目每次遇到此功能时都会崩溃:
#define SMW 29
float smw
getWert(&smw, SMW, rsq,rrq)
SMW是端口号码(kanal),我想得到" smw"
int MainWindow::getWert(float *erg, int kanal, mqd_t rsq, mqd_t rrq)
{
char *buff;
struct mq_attr attr;
struct mqs qmsg;
qmsg.msg=GETDATA;
qmsg.dat.kanal=kanal;
qmsg.dat.typ='d';
mmqueue mq;
mq.sdcmd(rsq,(char *)&qmsg, sizeof(qmsg));
mq_getattr(rrq, &attr);
buff = (char *)malloc(attr.mq_msgsize);
mq_receive(rrq, (char *)buff, attr.mq_msgsize, NULL);
*erg=atof(buff);
//qDebug()<<"GetWert"<<*erg;
return 1;
}
attr.mq_msgsize = 8192
global.h:
struct mqs{
unsigned int msg;
char mess[30];
kanaldef dat;
mmqueue.h:
class mmqueue
{
public:
int sdcmd (mqd_t sq, char *buf, int len);
};