Macro definition error in C?
问题 #define SOUND_SPEED 0.034; int rtt; //round trip time in microsecond double distance; distance = (double)(rtt*SOUND_SPEED)/2; It complains error: expected expression before '/' token. Was is it bacause I can't use macro to define decimals or what? 回答1: Drop the semicolon: #define SOUND_SPEED 0.034; ^ If you keep it the generated code will look like this: distance = (double)(rtt*SOUND_SPEED;)/2; ^ 回答2: #define SOUND_SPEED 0.034; ^ Do not use the trailing ; Actually you should never terminate a