I have an interface declared in its own header MyInterface.h:
class MyInterface{
public:
virtual ~MyInterface(){}
virtual void initialize() = 0;
virtual void newValueSound(int stream, double value) = 0;
virtual void newValueAlg1(int stream, double value) = 0;
virtual void newValueAlg2(int stream, double value) = 0;
};
Whenever I include this header and try to use the interface, for example:
#include "MyInterface.h"
void someMethod(){
MyInterface *interface;
}
I get strange compile errors on the line:
error C2332: ‘struct’ : missing tag name
error C2011: ‘<unnamed-tag>’ : ‘enum’ type redefinition
error C2226: syntax error : unexpected type ‘<unnamed-tag>’
What is wrong with my code?
EDIT:
Header has include guards.
I use Eclipse CDT with Microsoft compiler.
The whole header:
#ifndef MYINTERFACE_H_
#define MYINTERFACE_H_
class MyInterface{
public:
virtual ~MyInterface(){}
virtual void initialize() = 0;
virtual void newValueSound(int stream, double value) = 0;
virtual void newValueAlg1(int stream, double value) = 0;
virtual void newValueAlg2(int stream, double value) = 0;
};
#endif
and the class it is used in:
#ifndef MAIN_H_
#define MAIN_H_
#include <asio.h>
#include "Stream.h"
#include "MyInterface.h"
class MicApp {
private:
long inputChannelCount;
Stream **streams;
MyInterface *interface;
public:
MicApp(MyInterface *interface);
void initializeASIODrivers();
char **getDriverNames(int *numberOfDrivers);
bool loadDriver(char *driverName);
ASIOError initDriver(ASIODriverInfo *asioDriverInfo);
long getChannelCount();
double getSampleRate();
void activateStream(bool activate, int stream);
ASIOError startASIO();
ASIOError stopASIO();
ASIOError exitDriver();
};
#endif
Note that “Stream” is another class and it is used without any problems.
The thing was that the string “interface” is typedef’ed in ObjBase.h. So I cannot use “interface” as identifier. If I use another string as identifier, it works ok