C中的宏定义错误? [英] Macro definition error in C?

查看:282
本文介绍了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?

推荐答案

删除分号:

#define SOUND_SPEED 0.034; 
                         ^

如果保留它,则生成的代码将如下所示:

If you keep it the generated code will look like this:

distance = (double)(rtt*SOUND_SPEED;)/2;
                                   ^

这篇关于C中的宏定义错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆