简体   繁体   中英

Visual studio compiler errors at enum

I have the following code which compiles without errors under Linux and Mac OS X. I now want to compile the code with Windows, but I get a lot of errors in the following code segment:

...
enum Type   
    {
        UPDATE = 0, DELETE = 1
    };
...

The error messages are these:

1>Request.hpp(48) : error C2143: syntax error : missing '}' before '('
1>Request.hpp(48) : error C2059: syntax error : '<L_TYPE_raw>'
1>Request.hpp(49) : error C2143: syntax error : missing ';' before '}'
1>Request.hpp(49) : error C2238: unexpected token(s) preceding ';'

What did I wrong, I am really confused, as this compiles without errors under Linux. What can cause this errors?

The solution is quite easy, but one need to find out that DELETE is a Macro defined in the windows header.

I now added #undef DELETE and it works fine.

Type is an existing class. You need to change the name or specify that it's a literal.

You could try enum @Type to specify a literal, though you may need to prefix it with @ elsewhere.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM