C++ undeclared identifier when trying to create an instance of a struct

3k views Asked by At

I have a struct that is declared in a C++ header file with the line:

struct AII_Common_Export message{
    ...
};

I am then trying to create an instance of that struct in a C++ source file, so that I can set/ use some of the attributes stored in the struct:

message data;

However, when I compile my code, I get an "undeclared identifier" error on this line... I have included the header file in the source file, so I don't understand why I am getting this error- can someone explain it to me?

I also tried creating the instance of it with:

AII_Common_Export message data;

But then got the compile error: "syntax error: missing ';' before identifier 'data'.

Any ideas how I can fix this, so that I can create an instance of the struct?

EDIT

I have just found the AII_Common_Export definition- it is defined with:

#    define AII_Common_Export ACE_Proper_Import_Flag

and the ACE_Proper_Import_Flag is defined with:

#define ACE_Proper_Import_Flag __declspec (dllimport)

These two definitions are in separate header files.

1

There are 1 answers

5
Korbi On

Just do.

 struct message{
        ...
    };

message data;

see http://www.cplusplus.com/doc/tutorial/structures/