2
votes

I am trying to compile an older C++ program in Visual Studio 2013 Professional. I am encountering a compile error, with Visual Studio saying that there are syntax errors in the xtgmath.h file. The complete log is:

1> fill.cpp 1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(179): error C2059: syntax error : '('

1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(179): error C2027: use of undefined type 'std::enable_if'

1> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtr1common(67) : see declaration of 'std::enable_if'

1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(179): warning C4346: 'std::is_integral<_Ty>::value' : dependent name is not a type

1> prefix with 'typename' to indicate a type

1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(179): error C2988: unrecognizable template declaration/definition

1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(179): error C2143: syntax error : missing ')' before ','

1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(179): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(179): error C2059: syntax error : ','

1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(179): error C2059: syntax error : ')'

I have tried several different things that others have recommended, but none of it seems to work. I tried to run the preprocessor over the source file and examine the generated code, but it offered no insights. Does anyone have an idea about what's going wrong here?

1
My guess is a macro breaking things.T.C.
And this is why Microsoft was reluctant to support C99, lots of common short words dumped in the global namespace. But they had to, C++11 demands it. You'll have to chase down cbrt. Write your macros in all-capitals to avoid this kind of lossage.Hans Passant

1 Answers

0
votes

I was have the exact same error as you -- working with old code and now trying to compile it under VS2013. For me the problem was tied to this line of xtgmath.h:

_GENERIC_MATH1(round, _CRTSPECIAL)

I nailed it down to round being predefined in stdafx.h. In VS2013, round is already a built in function and having the definition override caused the compile errors.

To solve this I have commented out the round definition in stdafx.h.