-1

Possible Duplicate:
cmath compilation error when compiling old C++ code in VS2010
Compilation fails in VS2010 for C++ programs building fine in Linux

I am creating a program in C++ in which I need to read a text file in. I have included the fstream header file, which allows me to open the file, but having added the include, I now receive countless errors relating to math.h functions. Examples:

1>c:\program files\microsoft visual studio 10.0\vc\include\cmath(19): error C2061: syntax error : identifier 'acosf'
1>c:\program files\microsoft visual studio 10.0\vc\include\cmath(19): error C2059: syntax error : ';'

Is there any way I can include the text file reading functions of fstream without compromising the math.h functions? And why does this conflict occur anyway?

/Edit/

It seems the errors are in the cmath standard header file. It is nothing I have access to, but for the sake of completion, here is the code that is causing the errors:

using _CSTD acosf; using _CSTD asinf;
using _CSTD atanf; using _CSTD atan2f; using _CSTD ceilf;

(etcetera)

Community
  • 1
  • 1
CaptainProg
  • 5,610
  • 23
  • 71
  • 116
  • 2
    It would be nice to see the code which is causing this error. – Patrick B. Nov 22 '11 at 17:19
  • 2
    Post the code regarding those lines just to confirm there's no syntax errors (shit happens). – Grambot Nov 22 '11 at 17:19
  • 1
    Also, maybe [this](http://stackoverflow.com/questions/3141455/cmath-compilation-error-when-compiling-old-c-code-in-vs2010) and [this](http://stackoverflow.com/questions/3376224/ms-vc-iostream-compile-error) is helpful. – Alok Save Nov 22 '11 at 17:24
  • 4
    @CaptainProg: most of the time errors in header-file are caused by incorrect things in the file which includes them. That's we are asking for the code. – Patrick B. Nov 22 '11 at 17:28

1 Answers1

0

Compiling and running:

#include <fstream>
#include <math.h>

int main()
{
    std::ofstream f("test.txt", std::ios::out);
    f << std::acos((float)0);
    return 0;
}

There is already overloaded definitions for acos(double), acos(float), acos(long double) at math.h, there is no need to use acosf.

There is an error somewhere at your code.

Ian Medeiros
  • 1,746
  • 9
  • 24