View Single Post
Old Apr 15th, 2006, 8:48 AM   #4
rup
Newbie
 
Join Date: Jul 2005
Location: India
Posts: 14
Rep Power: 0 rup is on a distinguished road
Sorry for the incomplete post, should have followed intructions.
Here's the complete code:

The header gIPC.h:
#ifndef __GIPC_H__
#define __GIPC_H__

#include "gMsg.h"

class MessageQueue
{
	private:
		int qid;
		
	public:
		MessageQueue();
		~MessageQueue();
		void MsgSnd(Msg);
		void MsgRcv(Msg);
};

#endif // __GIPC_H__

The cpp, gIPC.cpp:
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include "gIPC.h"

MessageQueue::MessageQueue()
{
	qid = msgget(key_t(1234), 0666|IPC_CREAT);
}

MessageQueue::~MessageQueue()
{
	msgctl(qid,IPC_RMID,0);
}

void MessageQueue::MsgSnd(Msg m)
{
	msgsnd(qid, void*(&m), m.GetMsgSize(),0);
}

void MessageQueue::MsgRcv(Msg m)
{
	msgrcv(qid, void*(&m), BUFSIZE, m.GetMsgType(), 0);
}

This is the error:
rup@ubuntu:~/gui$ make
g++ -c gIPC.cpp
gIPC.cpp: In member function ‘void MessageQueue::MsgSnd(Msg)’:
gIPC.cpp:18: error: expected primary-expression before ‘void’
gIPC.cpp: In member function ‘void MessageQueue::MsgRcv(Msg)’:
gIPC.cpp:23: error: expected primary-expression before ‘void’
make: *** [gIPC.o] Error 1
rup is offline   Reply With Quote