Can you explain what the title error usually means?
I get it sometimes and I always eventually manage to fix it by accident, but I still don't have a clue what it means.
Here's an example from my current error:
Lca<RankVec, VertexVec> lca(graphList[0], dset, ss&);
error: expected primary-expression before ')' token
This typically means that your code is missing a closing '}'. For every opening '{' there should be a closing '}' expected primary-expression before ')' token. Sometimes this happens when the variable passed into a function isn't the type the function expected.
A “define” replaces the text before the compiler starts compiling. A “const int” is a fixed number and is a little more preferred for pin assignments.
Primary expressions are the building blocks of more complex expressions. They may be constants, identifiers, a Generic selection, or an expression in parentheses.
Hard to tell without any sample, but IIRC this happens as a consequence of using an undefined symbol (e.g. a function or a type without a declaration - not sure which exactly). In consequence, the parser gets confused and doesn't know what to expect further on in the code.
-(I believe this error only appears in conjunction with other errors? Or can you provide a code snippet which would give only this error on GCC compiler?)-
edit: In the code you provided, it is just the parser getting lost after encountering a "&" symbol in an illegal place - so a consequence of invalid syntax, not invalid semantics.
Such cryptic error messages (or often worse) are the consequence of the fact that C++'s grammar is undecidable and the compiler, upon seeing an error, cannot really guess what was supposed to be there and thus cannot generate a more accurate description.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With