0

as title said,the code blow gives error with g++:

error: expected specifier-qualifier-list before ‘logType’

Code:

enum 
{
     log_memory,
     log_filesystem,
     log_default
}logType;

typedef struct
{
     logType type;
     void (*logPrint)(char* msg);

}logsystem;
1
  • By the way, in C++ the typedef trick for structs is not necessary. Just write struct logsystem { ... }; Commented Dec 18, 2011 at 2:09

2 Answers 2

3

This:

enum
{
    ...
} logType;

declares a variable, not a type. You want this:

enum logType
{
    ...
};

[Side-note: Usual C++ conventions are to have type-names start with a capital letter.]

Sign up to request clarification or add additional context in comments.

Comments

2

When declaring an enum you specify the name of it right after the word enum, it's not like using typedef to create an alias for a struct.

enum logType
{
     log_memory,
     log_filesystem,
     log_default
};

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.