This is a weird problem that I was wondering if anyone else had seen. We're writing cross-platform C++ code for Mac and PC, and this only occurs on Mac.
Say I have a class, whose .h file looks like this.
class X {
public:
int _myValue;
void myFunction();
}
And I have another class, whose .h file looks like this:
#include "X.h"
class Y {
private:
X _myObj;
}
This won't compile. We get an error indicating X is undefined. The solution is to add a forward declaration for X in the Y.h file, such as: class X;
We've been doing this for a while, but now we're getting into situations where it's not working so well. For example, if we have a .h file that has a templates method defined in the .h file, and that method references a method in another class, the compiler doesn't know anything about it. Likewise, if we reference an enum that's defined in a class that was included, the compiler doesn't recognize it (the workaround for this problem was to put the enum in a separate .h file, and it picked it up just fine).
It's almost as if while compiling the .cpp file the compiler isn't pulling in the data from the included .h file.
I was just wondering if anyone had seen anything like this, or had possible avenues of investigation.
Much thanks...