parse error before `('

M

MoCha

hi all,
the following problem has taken up a lot of my time n hence i'm
turning to the group.

i have a header file in which there r several class declarations (n a
separate file for the funcn defs). now, in a different src file i'm
dynamically creating objects of these classes. (i've included the
header file)

in one of such creations the compiler complains abt the parse error
at the name of the class.

the code is:
nw.transferPacket(time, WIRELESS, new Information(newMSS, MSS,
MHid, MH, hostList[MHid - 1].movementBuffer))

the compiler says:
"mhList.cpp:471: parse error before `(' "

other classes from the same header r used in the same way with no
problem. i've included guards in my header files n checked for
circular references.

i'll b grateful if someone could provide likely reasons for the
error.
 
L

lilburne

MoCha said:
i'll b grateful if someone could provide likely reasons for the
error.

Despite what you think you haven't included one of the types. Perhaps
its misspelt? Perhaps you cut&pasted stuff and now have the same guard
in more than one header file?
 
J

Janusz Szpilewski

MoCha said:
in one of such creations the compiler complains abt the parse error
at the name of the class.

the code is:
nw.transferPacket(time, WIRELESS, new Information(newMSS, MSS,
MHid, MH, hostList[MHid - 1].movementBuffer))

the compiler says:
"mhList.cpp:471: parse error before `(' "

Check if the file compiles correctly when you comment out this line. If
not check the code preceding the line the for a missing semicolon,
unclosed parenthesis and other similar problems.

Regards,
Janusz
 
M

MoCha

the following problem has taken up a lot of my time n hence i'm
turning to the group.

i have a header file in which there r several class declarations (n a
separate file for the funcn defs). now, in a different src file i'm
dynamically creating objects of these classes. (i've included the
header file)

in one of such creations the compiler complains abt the parse error
at the name of the class.

the code is:
nw.transferPacket(time, WIRELESS, new Information(newMSS, MSS,
MHid, MH, hostList[MHid - 1].movementBuffer))
the compiler says:
"mhList.cpp:471: parse error before `(' "

other classes from the same header r used in the same way with no
problem. i've included guards in my header files n checked for
circular references.

i'll b grateful if someone could provide likely reasons for the




the error was that the included header file was actually a different
version than the one i added my class to, of course with the same
name, n only this difference. since the inclusion was done indirectly
via several files, i couldn't (shame) catch it.

finally one bright mind saw my src file after preprocessing - the
perfect way to get to the root of this problem (using -E switch, as in
g++ -E <src>)

then it all clicked n worked :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,428
Latest member
RosalieQui

Latest Threads

Top