stevemu

I am using VS 2005 Express, for a header file(look like):

const MAXT = 1500; // maximum number of trades

enum EQUITYTYPE { // equity types
EQ_HIGHLONG, EQ_LOWLONG, EQ_CLOSELONG,
EQ_HIGHSHORT, EQ_LOWSHORT, EQ_CLOSESHORT,
EQ_HIGHTOTAL, EQ_LOWTOTAL, EQ_CLOSETOTAL,
EQ_MAXLONG, EQ_MAXSHORT, EQ_MAXTOTAL,
EQ_MINLONG, EQ_MINSHORT, EQ_MINTOTAL
};

class TRDSIM {

public: // initialization, update and cleanup methods
TRDSIM (void);
~TRDSIM (void);
void clear (void);
int update (float fo, float fh, float fl, float fc, int cb);
int update_tick (float fc, int cb);

//other codes...
};

I am getting the following error:

c:\ctrd\scicon2\tsim202\trdsim2.hpp(21) : error C2061: syntax error : identifier 'TRDSIM'
c:\ctrd\scicon2\tsim202\trdsim2.hpp(21) : error C2059: syntax error : ';'
c:\ctrd\scicon2\tsim202\trdsim2.hpp(21) : error C2449: found '{' at file scope (missing function header )
c:\ctrd\scicon2\tsim202\trdsim2.hpp(270) : error C2059: syntax error : '}'

What is wrong

Thanks!



Re: Visual C++ Express Edition Error C2061

Jonathan Caves - MSFT

This error usually, though not always, indicates that you are attempting to compile C++ code using the C compiler ... which thinks 'class' is an identifier and not a keyword.




Re: Visual C++ Express Edition Error C2061

stevemu

How do I make sure the compiler using C++ not C in VS project Thanks.



Re: Visual C++ Express Edition Error C2061

stevemu

I made sure that in project property I am using /TP, but still with the same error msg. What else could be wrong



Re: Visual C++ Express Edition Error C2061

Bite Qiu - MSFT

stevemu wrote:
I made sure that in project property I am using /TP, but still with the same error msg. What else could be wrong

Make sure the source files that using this header file has a ".cpp" extension rather than ".c", because compiler will treat ".c" file as C code no matter /TP is specified or not.