I have defined a constant as follows

 #define M_PI 3.14159265358979323846;

And I cannot use it as an argument in the pow-function

 double d = pow(M_PI * 2, 0.5);

That is - the squareroot of M_PI * 2

I get a cryptic syntax-error in eclipse

What is wrong with this code? Have no problem using the constant outside the function

有帮助吗?

解决方案

Remove the trailing semicolon from this line:

#define M_PI 3.14159265358979323846;

to have it look like this:

#define M_PI 3.14159265358979323846

Macros are expanded by the pre-processor before compilation, so the code passed to the compiler using your version would look like:

double d = pow(3.14159265358979323846; * 2, 0.5);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top