interpreting messages from compiler diags

Linda Walsh gcc@tlinx.org
Sat Jun 14 20:44:00 GMT 2014


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);

----

I.e. 'task' defines a "work" pointer to be done.
meter is a task that updates data and updates a display(window).

Am in a transition period going from a polling X11 based loop that calls the
data-updater & display function 'checkResources' based on a given meter's
request event sub returning true, which does so every 10 calls
 (! (++perMeterCounter%10)).

The newer call structure will call the data-updater+display based only
on some delta_t from the previous update -- i.e. my "work".

The scheduler only wants to pay attention to to the 'Task' vars (as it
contains the time-info + work pointer) and the Task vars should be
part of the Meter class.

My plan was to treat a Meter like a Task while it is in the scheduling 
Queue,
but when work is to be done, it will call the work as a Meter* based item.

Since Meter is a strict superset of Task (w/Task declared public), I should
(as  I understand it) be able to cast a pointer of a meter into a task and
vice-versa if the underlying object is really a meter.   

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??

The error messages are great, if I know all the 'nouns' that they refer
to!  At times like this I would wish for some more verbose error messages
that explain what the terms are -- or hyperlinked error messages...(in my
tty window?  hmmm).  Well, hopefully you get the idea.

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

(and secondarily(optionally), is my expectation of how things work,
 as described above, reasonably likely to work once
I get the syntax down? 


(I keep wandering from attempts to do this with indirect class notation,
vs. using stdlib 'functional' items, vs. lambda's... each have cryptic
syntax error messages referring to things that aren't very clear to me).

I'm sure any of them is solvable, knowing the nomenclature...(?)  ;-)


Thanks for tips on linguistic definitions used by the error messages...

linda



More information about the Libstdc++ mailing list