interpreting messages from compiler diags

Daniel Krügler daniel.kruegler@gmail.com
Sat Jun 14 20:52:00 GMT 2014


2014-06-14 22:44 GMT+02:00 Linda Walsh <gcc@tlinx.org>:
> Most of the g++ error messages are pretty helpful, but sometimes
> they use nouns that don't have a clear definition...
>
> In trying various combinations 'static_cast' as in:
>
> [ltask.h:]
> class Task {
> public:
>    function<void(void)>work{};[ltask.h]
>    ...
> [meter.h:]
> class Meter: public Task {
> ...
>
> [meter.cc including ltask.h:]
>    work = static_cast<void>(Task::*())(&Meter::checkResources);
> --- errors:
>  g++: COMPILE meter.cc
> meter.cc: In constructor 'Meter::Meter(XOSView*, const char*, const char*,
> bool, bool, bool)':
> meter.cc:23:33: error: expected unqualified-id before '*' token
>  work = static_cast<void>(Task::*())(&Meter::checkResources);
>                                 ^
> meter.cc:23:35: error: expected primary-expression before ')' token
>  work = static_cast<void>(Task::*())(&Meter::checkResources);

[..]

> My problem is getting the syntax of this type interpretation to work, but
> not knowing the error messages in c++ well enough to know what it
> wants.  i.e. "unqualified-id"?  "primary-expression"?  What are those
> and how woudl they differ from qualified or non-primary??

"unqualified-id" and "primary-expression" are names for particular
grammar elements of the C++ language, they are not nouns of anyone's
daily vocabulary (except for compiler writers).

> Where can I look up all these 'nouns' to find out what they mean?

The grammar of C++ is defined by the ISO C++ Standard. You can find a
recent draft of the standard at this link, for example

http://www.open-std.org/jtc1/sc22/wg21/prot/14882fdis/n3936.pdf

- Daniel



More information about the Libstdc++ mailing list