Interptreting g++ compile error readout

Hi,
I'm beginning in C++ with someone else's code that I am changing to suit my purpose. After making my changes there are many compile errors. I have worked my way through most, but have had to play around a bit to correctly interpret the way some of the errors display. One error regards a function that has another function as an argument, and it seems when I call that function there is some mismatch between it and the one declared in the header:

code/ceelirf.cpp:362:61: error: no matching function for call to ‘ceelirf::NewtRoot(void (ceelirf::*)(ceelirf::ftuple&, reell, reell, reell), reell&, reell&, reell&)’
code/ceelirf.cpp:289:7: note: candidate is: reell ceelirf::NewtRoot(void (*)(ceelirf::ftuple&, reell, reell, reell), reell&, reell&, reell&)

fyi reell is a defined type, ftuple is structure, and ceelirf is the class. The two strings match except for what's in the parentheses after 'void'. One is 'ceelirf::*' while the other is just '*'. The declaration of NewtRoot in the header file is:

The definition of NewtRoot in .cpp file is:
 
reell ceelirf::NewtRoot(void (*funcd)(ftuple&, reell, reell, reell), reell& tguess,reell& C1,reell& C2)

The call of the function is
 
estSpikeTime[n]= NewtRoot(&ceelirf::FComplex, tguess,C1,C2);

Any ideas as to why I get the compile error? Is it really the mistmatch of the strings that gives the error? That would mean that from a function call of NewtRoot where the argument is a function of a particular class, the compiler is looking for a definition of NewtRoot where the first argument is also a member fucntion. But I thought arguments in function definitions are for defining the type, and a class membership criteria seems exraneous to that purpose. Am I wrong?

Thanks for reading,

Max
Last edited on
The declaration of NewtRoot in the header file is:

reell NewtRoot(void (*funcd)(ftuple&,reell,reell,reell), reell&,reell&,reell&);
Are you totally sure about this? The compiler wouldn't make a mistake reading the types. Could it be that something weird is happening, such as you reading a different version than the compiler?

And more generally, I was wondering if someone could post a link to some official/readable g++ compiler error rulebook.
The thing is, compiler errors aren't really meant to provide insight about the problem. You're supposed to read errors as the compiler saying "look, this line here has a problem, and here's a vague suggestion about what it might be. Figure it out." Some compilers have better error messages, but they're usually not very different. You'll eventually be able to know what the compiler means when it complains without reading too carefully, but it'll take many thousands of lines.
void (*)(... this is a pointer to non-member function (returning void)
void (ceelirf::*)( this is a pointer to member function (of class ceelirf), returning void

pointers to member functions and pointers to non-member functions are two completely different concepts, and are not interchangeable (or even convertible).
Last edited on
Thanks helios. I should probably start with KDevelop debugging environment, then.

Cubbi. But isn't it true that in a function decalration where an argument is a function, there is no need to specify whether or not that argument function is a member of a particular class (it is just s data type specific place holder, right?). My confusion comes from the fact that the compiler seems to indicate that it is looking for just that since that's how it reads the string holding the function call.
Topic archived. No new replies allowed.