C Getting error while calling a non-member function in a class method

Hi,

I've a stack_trace class declared as following. to print the stacktrace I rely on a method which is implemented in some other library.

Code:
class Stack_trace
{

private:
// Don't allow to create object directory
Stack_trace();
Stack_trace(const Stack_trace&);
Stack_trace& operator=(const Stack_trace&);

virtual ~Stack_trace();

static Stack_trace * m_stack_trace;
void print_disclaimer();

public:
friend class Stack_trace_destroyer;
static void init_instance();

static Stack_trace& get_instance();
void print();

};

void Stack_trace::print()
{
print_disclaimer();
::my_print_stacktrace();

}
Above code compiles on almost all other Windows and non-windows platforms except FreeBSD
When I try to call the method e.g. ::my_print_stacktrace() in the public method I get following error:
Code:
error: '::my_print_stacktrace' has not been declared
I've included the header where this method is declared. That's the reason it compiles on other platforms. It seems compiler on FreeBSD is still not able to find the function declaration OR expecting it to be a member function of the class.

Question is how do I compile this code ?
 
Last edited by a moderator:
I've included the header where this method is declared.

You probably need to add another -I parameter to your compiler command line to tell the compiler the directory to look in for this header.
Code:
c++ -I/home/me/myIncludeFolder -c Stack_trace.cpp
Every OS / compiler combination pretty much has their own definition of the "default" places to look for include files, and you have to use the -I option to point to folders outside of those defaults.
 
Thanks I'll try this out. But, I am just wondering if that would be the reason then code would not have compiled in case if I call that method from a normal method (e.g. not from class methods) in my source file. In that case it compiles without any problem.
 
I've found the source of problem. my_print_stacktrace() method was hidden deep down under a macro in the header file. Once I enabled that macro, code compiled.
Thanks for help.
 
Back
Top