3

i've recently added Google's V8 to a MSVC2005 project which is also using Qt and i haven't been able to compile it since. The defines are giving me a lot of problems, for example in V8's token.h there is

#define T(name, string, precedence) name,
enum Value {
TOKEN_LIST(T, T)
NUM_TOKENS
};

The line TOKEN_LIST(T, T) yields an error C2143 ('}' missing before '{'), also error C2059 (syntax error '{'), also C2334 (token before '{'; visible function text is skipped). This repeats itself a couple of times.

I have searched through SO and through Microsoft's database and tested various things, for example using /clr, which broke Qt. I also used #undef before including the "v8.h" file for possibly existing definitions to be removed.

Can anyone help with this? Is there a standard procedure to fix errors like this? Thanks.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Traveller
  • 41
  • 4

1 Answers1

2

You can find the conflicting macro definitions by searching for differences between the preprocessed code generated for token.h with and without the #include <windows.h>.

For example, for "token.h", the errors occur at the definition of the enum Value so you have to look at the preprocessed definition of that enum in both cases. So with

    #include <windows.h>
    #include <token.h>

you get:

enum Value {
    ...
    INSTANCEOF, , NOT, BIT_NOT, (0x00010000L), TYPEOF, void, BREAK,
    ...
    SWITCH, void, THROW,
    ...
    FUTURE_STRICT_RESERVED_WORD, const, EXPORT,
    ...
};

instead of:

enum Value {
    ...
    INSTANCEOF, IN, NOT, BIT_NOT, DELETE, TYPEOF, VOID, BREAK,
    ...
    SWITCH, THIS, THROW, 
    ... 
    FUTURE_STRICT_RESERVED_WORD, CONST, EXPORT,
    ...
};

with only #include <token.h>.

Community
  • 1
  • 1
alexisdm
  • 29,448
  • 6
  • 64
  • 99
  • How can i explicitly remove the windows.h include? I did not add it and it's not in the token.h. Sorry for my lack of knowledge and thanks. – Traveller Mar 05 '12 at 18:15
  • @Traveller: You could for example create a new .cpp file, with only 2 lines `#include ` and `#include `, and run that file through the preprocessor. – alexisdm Mar 05 '12 at 18:22
  • Thank you. Unfortunately the files match. – Traveller Mar 05 '12 at 18:31
  • They didn't when I tried... By comparing the `Value` enum in both cases, I found 5 macros that were replaced by something else: `IN`, `DELETE`, `VOID`, `THIS`, `CONST`. Maybe you have to disable precompiled headers for the file. – alexisdm Mar 05 '12 at 18:39
  • So i cleaned the project, disabled precompiled headers and used windows.h + token.h one time and only token.h the other, but the generated .i-files match completely. Hmm – Traveller Mar 05 '12 at 19:16
  • @Traveller I retested starting with an empty Win32 project in Visual C++ 2010 (I was using "gcc -E" + wine's windows.h on linux before) and it seems to work, so I'm not sure what you did differently... – alexisdm Mar 08 '12 at 13:35