I have this old C++ project I'm compiling. It wasn't written by me. I'm attempting to compile it for someone I know. The code dates way back to the early 1990s, late 1980s, though some of it was still developed circa 2008 or so. Although I see Visual Studio 2013 was used. I'm attempting to compile it in VS 2015. Long story short, I'm getting an error where the "vector" is included. In vector "cmath" is included and that's where the errors crop up. Apparently this code was successfully compiled in earlier versions of Visual Studio, i.e. 2013 or 2010.
This is a large project, so it's hard to present this fully, but here is the top of the source file where vector is included:
#ifndef EXPRESSAPPLICATION_H
#define EXPRESSAPPLICATION_H
#pragma warning (disable : 4786)
#include <windows.h>
#include <vector>
#include "ObjList.h"
Here is the error list:
Severity Code Description Project File Line Suppression State
Error C2062 type 'double' unexpected ExpressOffice C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath 17
Error C2059 syntax error: ')' ExpressOffice C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath 17
Error C2143 syntax error: missing ';' before '{' ExpressOffice C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath 18
Error C2447 '{': missing function header (old-style formal list?) ExpressOffice C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath 18
Error C2062 type 'float' unexpected ExpressOffice C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath 30
Error C2059 syntax error: ')' ExpressOffice C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath 30
Error C2143 syntax error: missing ';' before '{' ExpressOffice C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath 31 Error C2447 '{': missing function header (old-style formal list?) ExpressOffice C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath 31
Error C2062 type 'long double' unexpected ExpressOffice C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath 328
Error C2059 syntax error: ')' ExpressOffice C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath 328
Error C2143 syntax error: missing ';' before '{' ExpressOffice C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath 329
Error C2447 '{': missing function header (old-style formal list?) ExpressOffice C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath 329
Here are the lines of code it's complaining about in cmath:
line 17:
_Check_return_ inline double abs(_In_ double _Xx) _NOEXCEPT
{
return (_CSTD fabs(_Xx));
}
line 30:
_Check_return_ inline float abs(_In_ float _Xx) _NOEXCEPT
{
return (_CSTD fabsf(_Xx));
}
line 328:
_Check_return_ inline long double abs(_In_ long double _Xx) _NOEXCEPT
{
return (_CSTD fabsl(_Xx));
}
It appears that only the abs() functions in cmath are affected. None of the other math functions are affected. I'm mystified by this problem. Thanks for any help on this!
abs
tostd::abs
andfabs
tostd::fabs
. – Jesper Juhlwindows.h
defines a macro forabs
. You could insert something like#ifdef abs #undef abs #endif
after includingwindows.h
(in separate lines, of course). – chtz#include <vector>
before#include <windows.h>
, might help without manual undefs? – CiaPan