PDA

View Full Version : Preeprocessor Errror



newport_j
January 3rd, 2011, 10:52 PM
ifdef _cplusplus
#include <complex>
typedef complex<double. dcomplex;
#else
#include <complex.h>
typedef double complex dcomplex;
#endif




In file included from WEGtest.c:17:
sel_lang.h:6: error: expected initializer before ‘dcomplex’


The code at the top resulted in an error message that follows the code. I am unsure as to what it means. I took this code literally from a previous post.

I did get a deprecated header warning (not shown) so is that the problem? This is by no means all of the output, but the warning and the error shown are the first two phenomenon when I compile.

It seems that there is nothing wrong with the code.

I am unsure what to do next.

Why do I have this error?

Any help appreciated, Thanx in advance.

Newport_j

GeneralZod
January 3rd, 2011, 10:57 PM
typedef complex<double. dcomplex;




There's at least one error, there ("." instead of ">").

MadCow108
January 3rd, 2011, 11:03 PM
please read the new answers in your other thread
your on the completely wrong track and wasting your (and our) time

newport_j
January 4th, 2011, 04:23 PM
I think that I see the problem. The precompiler directive _cplusplus should have a double underscore __cplusplus.

That is at least one error.


Newport_j

newport_j
January 4th, 2011, 10:02 PM
I think I have most of the errors out, but one remains. The preprocessor directive is:



#ifdef __cplusplus
#include <complex>
typedef complex<double> dcomplex;
#else
#include <complex.h>
typedef double complex dcomplex;
#endif


This results n the following error on compiling.

In file included from WEGtest.c:17:
sel_lang.h:3: error: expected initializer before ‘<’ token



It clearly does not like the third line of this directive.

typedef complex<double> dcomplex;

I believe that is not recognizing the term complex. I have found the complex file for c++ complex numbers so I knw it exists. But why am I getting the error? I choose to write this program in c++ so I must use something like the above to introduce and use complex numbers. This is one way in c++.


In Stanley Lippman's, C++ Primer, 2 ed on page 65 this is exactly how he does it syntactically; he of course usess a different example. I have also seen other code that does it this way. I am just not sure why i am gettng the error.

This should work. Any help appreciated, Thanx in advance.


Newport_j

worksofcraft
January 4th, 2011, 10:47 PM
I think I have most of the errors out, but one remains. The preprocessor directive is:



#ifdef __cplusplus
#include <complex>
typedef complex<double> dcomplex;
#else
#include <complex.h>
typedef double complex dcomplex;
#endif


This results n the following error on compiling.

In file included from WEGtest.c:17:
sel_lang.h:3: error: expected initializer before ‘<’ token



It clearly does not like the third line of this directive.

typedef complex<double> dcomplex;

I believe that is not recognizing the term complex. I have found the complex file for c++ complex numbers so I knw it exists. But why am I getting the error? I choose to write this program in c++ so I must use something like the above to introduce and use complex numbers. This is one way in c++.


In Stanley Lippman's, C++ Primer, 2 ed on page 65 this is exactly how he does it syntactically; he of course usess a different example. I have also seen other code that does it this way. I am just not sure why i am gettng the error.

This should work. Any help appreciated, Thanx in advance.


Newport_j


my first guess is that you need to specify:


using namespace std;