Question

Having a problem using enumerations with namespaces.

Below is the function call:

object->writeMessage(tmpZone->getLineOne(), tmpZone->getLine(), tmpZone->getPosition());

the problem from the compiler comes from

tmpZone->getLine()

the prototype for getLine() from the Zone class(which is in the insight namespace)is:

Line getLine();

which returns an enum type in the insight namespace. This function call is in a cpp file under a using namespace insight; line.

the compiler errors are

C:/WindRiver/workspace/SimpleTemplate/InsightLT.cpp: In static member function static int insight::InsightLT::taskFunction(insight::InsightLT*)': C:/WindRiver/workspace/SimpleTemplate/InsightLT.cpp:161: error: no matching function for call to insight::InsightLT::writeMessage(std::string, Line, int)' C:/WindRiver/workspace/SimpleTemplate/InsightLT.cpp:82: note: candidates are: void insight::InsightLT::writeMessage(std::string, insight::Line, int)

I can't think of why this is happening. The Zone class is defined with in the insight namespace as well. Any ideas guys?

No correct solution

OTHER TIPS

Compiler can't resolve Line from insight namespace, you could provide full namespace in function definition, also wrap cpp inside namespace insight.

Try:

namespace insight {
  void InsightLT::writeMessage(std::string, insight::Line, int)
  {    
  }
}

I was able to get this to compile, though I don't know why what I did worked. For the sake of completeness and closure I wanted to put it here.

I was declaring the Line enum and another enum inside the namespace scope along with another class. I removed the enums and put them in their own header files within the same namespace as before and it now compiles.

I am not sure what I was missing that this fixed the issue. If someone has any considerations please comment as to what this might have fixed.

Thanks for those that tried to help and sorry I wasn't able to put together an example the displayed the error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top