I've inherited some older code, that in the past has built, but is now failing,
and giving the error that friend functions are not defined in this scope,
I'm including excerpts from the code:
In the .h file:
// LibE Query class
// note this is an abstract class, the user must define queryCb
class eQuerier {
friend int _eQuerierCb(void*,const G2DESC*,void*);
protected:
virtual int queryCb(const G2DESC*,void*) = 0;
public:
const char *query(const char *exp) {
return eQuery(exp,_eQuerierCb,this);
};
};
Note eQuery is defined in a support library.
in the .C file:
int
_eQuerierCb(void* arg,const G2DESC* desc,void* msg)
{
return ((eQuerier*)arg)->queryCb(desc,msg);
}
error:
In file included from ooe.C:4:0:
ooe.h: In member function const char* eQuerier::query(const char*):
ooe.h:110:21: error: _eQuerierCb was not declared in this scope
return eQuery(exp,_eQuerierCb,this);
Add a line int _eQuerierCb(void*,const G2DESC*,void*);
just before class eQuerier {
Or, for a more typical approach, make sure it appears in the header file for that "support library", and #include that file before class _eQuerierCb is defined.