![]() |
error: expected primary-expression...
I am in Linux, using g++ to compile.
My code looks like this: This is the header: :
class TestIn a cpp file I have the declaration: :
void Test::Function(...)I got this error when compiling: ....error: expected primary-expression before ‘void’.... What does this mean. BTW, the code fragments are highly simplified and only a part of a programming project. But the interface is similar. Can somebody help? |
You show an error that says, "expected primary-expression before 'void'..." Then you show us a snippet with everything before 'void' snipped out....hilarious. Incidentally, that's the definition in the cpp file, the declaration is in the class. Did you mean to have those three dots in the arg list in the definition and not up in the declaration?
|
As Dawei said, the code snippets given do not give any useful information. It is better to find a SMALL but COMPLETE example that repeatably illustrates your problem (and post it verbatim in code tags). I recommend you read the sticky threads on "How to ask a question" as well .... they give advice on how to ask a question to increase your chances of getting a useful response.
The most common reasons the compiler would expect an expression before a function declaration or definition are a missing closing brace i.e. } or a missing semi-colon (or possibly both). But, given that you haven't provided enough information, that is only a stab in the dark. |
Sorry for the incomplete post, should have followed intructions.
Here's the complete code: The header gIPC.h: :
#ifndef __GIPC_H__The cpp, gIPC.cpp: :
#include <sys/types.h>This is the error: :
rup@ubuntu:~/gui$ make |
:
SYSTEM CALL: msgsnd(); |
:
msgsnd(qid, void*(&m), m.GetMsgSize(),0); |
I picked msgsnd from the book Beginning Linux Programming (Wrox).
It has the following prototype: :
int msgsnd(int msqid, const void* msg_ptr, size_t msg_sz, int msgflag);:
msgsnd(msgid, (void*)&some_data, MAX_TEXT, 0);:
struct msg{Yes, I meant to cast it. |
So, did that clear your error message or not? Inquiring members want to know. It's the fee.
|
Yes, it cleared my error message.
I hade written this: :
msgrcv(qid, void*(&m), BUFSIZE, m.GetMsgType(), 0);Because in C++ a cast is applied this way : void(variable) I had left it that way. Making it (void*)(&m) solves the problem. |
Excuse me? :confused:
|
| All times are GMT -5. The time now is 11:04 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC