yesterday I broke my project. Wouldn't compile anymore.
It's a big project started time ago and consists of many translation units.
Over time I have applied quick changes, fixes, substituted old versions of objects with new ones...
Short story: I had a messy chain of dependancies, with multiple class forwardings, repetition of typedefs, and such.
So yesterday the problem gets serious: can't go any further if I don't clean the mess.
I do it.
Now the inclusions are more straightforward, and the whole is so much cleaner.
But 1 symbol is not recognized.
Error C2143: syntax error: ';' missing before '*'
It's a classic.
The weird thing is that the missing symbol is not missing.
Instead it's fully defined in the header (ClassA.h) that's being included immediately before the one header (ClassB.h) into which the error bumps.
Here is a better explanation of the situation:
(NOTE: There are include guards in each header)
//------------------------------------------------------------
FILE: Master.h
#include "Types.h"
#include "ClassA.h"
#include "ClassB.h"
//------------------------------------------------------------
FILE: Types.h
... // No includes. This header houses simple UDTs, typedefs, and
// other stuff that is independant of other translation units.
// Touching Types.h triggers a full rebuild (ouch!)
//------------------------------------------------------------
FILE: ClassA.h
#include "Master.h"
class ClassA
{
// full definition of ClassA
};
//------------------------------------------------------------
FILE: ClassB.h
#include "Master.h"
class ClassB
{
ClassA* pA; // at this point 'ClassA' token is not defined
};
After seeing the error, I have quit the IDE.
I have deleted the Debug builds and all .ncb files, just to be sure.
Then I recompiled from scratch.
ClassA.cpp gets compiled before ClassB.cpp, as expected. Yet the error persists.
The solution is to forward "class ClassA;" inside ClassB.h. I understand why.
Instead I don't get why it doesn't 'see' the full definition of ClassA.
Anyone can tell me?
Regards,
Ciao ciao : )












