0

I am working on some simulation software, written in C++. Currently, when trying to build my code, I get 9 compile errors, all complaining about the three lines of code that I've just added. Those lines are the declarations in PublisherModule.h:

class PublisherModule :
    public s::Module,
    public s::Singleton<PublisherModule>,
    public s::Interface,
    public s::htmlPage{
    
    public:
        ...
        Types::ModeRecord;
        ModeRecord modeData;
        ModeRecord *modeDataPtr;
    ...
};

The reason for adding these declarations into the PublisherModule.h was so that I could add the following code into the publish() function of the PublisherModule.cpp file:

Types::ModeRecord ModeData;
Types::ModeStatusRecord *ModeDataPtr = &ModeData;
DataStore->getModeData(*ModeDataPtr);

The publish() function now looks like this:

void PublisherModule::publishData(void){
    ...
    Types::ModeRecord ModeData;
    Types::ModeStatusRecord *ModeDataPtr = &ModeData;
    DataStore->getModeData(*ModeDataPtr);
    ...
}

The errors that the compiler is giving me are:

error C2653: 'Types': is not a class or namespace name

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

error C2146: syntax error : missing ';' before identifier 'ModeData'

error C2143: syntax error : missing ';' before '*'

I get error C4430 4 times in total, and the other errors all once each. They are all complaining about the lines that I added into the .h file. Having Google'd the first error, and come across this answer on SO: Compiler error C2653: not a class or namespace name , it would appear that the cause is a circular dependency in the header files...

But that is not happening here as far as I can tell... Are there any other reasons why I might get this compile error, and what's preventing my code from building?

The message displayed when I hover my cursor over the first line that I've added in the .h file, Types::ModeRecord is:

Error: a class-qualified name is required

Community
  • 1
  • 1
Noble-Surfer
  • 3,052
  • 11
  • 73
  • 118
  • At which line in the source code do you get the error message `error C2653: 'SIFFTypes': is not a class or namespace name`? – wimh Sep 09 '15 at 15:43
  • Sorry, typo in my questions there- fixed now. It's the line just above `Types::ModeRecord;` in the `.h` file. That particular line is actually just a comment- there is no executable code on it. – Noble-Surfer Sep 09 '15 at 15:50

1 Answers1

3

Here is an abbreviated version of the code you posted, with my observation:

class PublisherModule [... bunch of base classes...]
{

public:
    Types::ModeRecord;
};

What do you think this line does??
Types::ModeRecord;

It is not of the form [TypeName] [VariableName]; (eg int i;)
It does not look like a method prototype (eg void foo(int i);)
It is not a typedef.
It doesn't look like any normal C++.

What do you think it is doing?

abelenky
  • 63,815
  • 23
  • 109
  • 159