Reputation: 335
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!
Upvotes: 12
Views: 22854
Reputation: 324
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' ;)
Upvotes: 6
Reputation: 17186
Are you sure it's compiling as C++? Most compilers will compile .C file as C and .cpp files as C++, compiling a C++ file with a C-compiler will probably fail.
Also, that code mixes oldstyle ('c') headers and newstyle ('c++') headers. It should be more like this (I doubt that is the error however).
#include <fstream>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
That's all I can see with what you've given. But most of the time when you get errors in library files of C/C++ itself, it still is code of you that's wrong somewhere, like forgetting the ; after a class statement in a header file.
Upvotes: 15