Compilation error "cstdio standard header"

Hello all

I have a C-file with some header files as follows
1
2
3
4
5
6
#include <iostream>
#include <math.h>
#include <vector>
#include <float.h>
#include <complex>
#include <cmath.h> 


When I try to compile, I got no idea why it should give me a compilation error in "cstdio standard header". The error I get is like
C:\Programme\Microsoft Visual Studio 9.0\VC\include\cstdio(39) : error C2143: syntax error : missing '{' before ':'


Its like 1000 errors...!! Does anybody know why this happens? I was far better off using Visual Studio-6 and am cursing myself to have shifted to Visual Studio-2008.
There are two math headers: math.h and cmath. Include one or the other (preferably cmath). It's cmath, not cmath.h.
I had that as cmath, but was just experimenting trying with cmath. Actually, these headers should not matter as it coompiled beautifully as a standalone file in 'Bloodshed Dev-C++'. When I made a project in Visual-C++, I got bombarded with errors. :(

Thats why I asked if there is any special setting needs to be done.
You'll have to post more, then. This kind of errors happen when there's an unclosed brace before the inclusion of the header. For example:
1
2
3
4
5
6
7
8
9
10
11
//a.h
struct something{
//...

//(no })

//main.cpp
#include "a.h"
#include <iostream>

//... 
equationsolver.h
1
2
3
4
5
extern std::vector< std::vector<double> > QuadRoots( double, double ,double);
extern std::vector< std::vector<double> > CubicRoots( double, double,double, double);
extern std::vector< std::vector<double> > QuarticRoots( double, double ,double , double , double);
extern std::vector< std::vector<double> > BiquadRoots( double , double ,double , double , double);
extern std::vector<double> complex2real( std::vector< std::vector<double> >, double );


equationsolver.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <math.h>
#include <vector>
#include <float.h>
#include <complex>
#include <cmath>
using namespace std;



/**************************************************************************/
/**************************************************************************         
          FUNCTION-NAME: QuadRoots
                PURPOSE: To solve a quadratic equation
       INPUT PARAMETERS: equation co-efficients a, b, c                                                                  
       RETURN PARAMETER: vector<double> - roots
***************************************************************************
/**************************************************************************/

 std::vector< std::vector<double> > QuadRoots( double a, double b,double c)
 {	 
	 std::vector< std::vector<double> >  all_roots;       /* Op Vector */
	 std::vector<double> root(2, 0.0);                    /* root      */
     double d;                                        


	 d = b*b - 4*a*c;

	 if((a==0.0)&&(b==0.0))
	 {
		 cout<<"\n\nERROR: Empty vector will be returned";	 
	 }
	 else if(a==0.0)
	 {
		 root[0] = -c/b;
		 all_roots.push_back(root);	 	 
	 }
	 else if(d<0)
	 {
		 root[0] = -1.0*b/(2*a);
		 root[1] = sqrt(-1.0*d)/(2*a);
		 all_roots.push_back(root);
		 root[1] = -1.0*root[1];
		 all_roots.push_back(root);
	 }
	 else
	 {
	 
	   root[0] = (-b + sqrt(d))/(2*a);
	   all_roots.push_back(root);
	   root[0] = (-b - sqrt(d))/(2*a);
	   all_roots.push_back(root);	 
	 }
   
	 
     /* Return the calculated roots */   
     return (all_roots);
 }

/**************************************************************************/
/************************END OF QuadRoots() function***********************/
/**************************************************************************/ 
.
.
.
.


The code is quite big but its basically the definitions of each function!
I cant believe the stupidity!! The filename needs to have a .cpp or .cxx extension and not .c.

Crazzzzzy

Topic archived. No new replies allowed.