Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cmath compilation error when compiling old C++ code in VS2010

I've inherited a few C++ files and an accompanying makefile, which I'm trying to bring into VS2010 as a solution. I've created an empty project and added the appropriate C++ and header (.hpp) files for one of the makefile targets.

When I try to compile the project, however, I immediately get a large number of C2061 (syntax error identifier) errors coming from cmath regarding acosf, asinf, atanf, etc.

The error line in cmath:

#pragma once
#ifndef _CMATH_
#define _CMATH_
#include <yvals.h>

#ifdef _STD_USING
   #undef _STD_USING
     #include <math.h>
   #define _STD_USING

#else /* _STD_USING */
   #include <math.h>
#endif /* _STD_USING */

#if _GLOBAL_USING && !defined(RC_INVOKED)

_STD_BEGIN
using _CSTD acosf; using _CSTD asinf;

The top block of the relevant C++ file (though named as a .C):

#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

Followed by the main() function, which doesn't call any of the trig functions directly. This has to be something really obvious, but I'm missing it. Can anyone help?

Thanks!

like image 840
Mike O'Malley Avatar asked Jun 29 '10 14:06

Mike O'Malley


1 Answers

Its probably NOT compiling as C++ code - as you assume. I am going to ask you to right click on the file in vs2010, click properties, go to 'Configuration Properties - C/C++ - Advanced', and make sure 'Compile As' is set to 'Compile as C++ Code (/TP)'.. If not, change it to that, then recompile.. you may have to recreate your Pre-compiled Headers, but I am going to be this fixes your 'problem' ;)

like image 167
Jay Kramer Avatar answered Sep 22 '22 09:09

Jay Kramer