Compiler Error 29
expected an expression¶
Consider this code sample:
#include "mbed.h"
#include "math.h"
#define PI =3.1415
AnalogOut signal(p18);
int main()
{
double n;
while(1)
{
for(n=0;n<361;n+=10)
{
n=sin(30*PI/180); // Get error 29: expected an expression here
}
}
}
The line which causes the error expands from
n=sin(30*PI/180);
to
n=sin(30*=3.1415/180);
The extra '=' assignment operator in the middle of this expression is incorrect. The cause is in the #define for PI earlier in the program. The '=' assignment operator shouldn't have been used and PI defined like this instead:
#define PI 3.1415