错误:预期标识符或'('之前,宏定义

时间:2012-06-08 18:18:59

标签: c c-preprocessor

我在尝试定义这个类似函数的宏时遇到了麻烦,它采用4个向量幅度来表示一般柱面顶面的长轴和短轴,并确定一般柱面的类型。 EQUAL是一个已定义的宏,用于查看两个浮点值是否等于"彼此。

3080 #define GET_TGC_TYPE(_type, _a, _b, _c, _d) { \
3081     if (EQUAL((_a), (_b)) && EQUAL((_c), (_d))) { \
3082         /* circular base and top */
3083         if (EQUAL((_a), (_c))) { \
3084             /* right circular cylinder */
3085             (_type) = RCC; \
3086         } else { \
3087             /* truncated right cone */
3088             (_type) = TRC; \
3089         } \
3090     } else { \
3091         /* elliptical base or top */
3092         if (EQUAL((_a), (_c)) && EQUAL((_b), (_d))) { \
3093             /* right elliptical cylinder */
3094             (_type) = REC; \
3095         } else { \
3096             /* truncated elliptical cone */
3097             (_type) = TEC; \
3098         } \
3099     }
3100 }

我得到的错误是

3083:9: error: expected identifier or ‘(’ before ‘if’
3086:11: error: expected identifier or ‘(’ before ‘else’
3090:5: error: expected identifier or ‘(’ before ‘}’ token
3090:7: error: expected identifier or ‘(’ before ‘else’
3100:1: error: expected identifier or ‘(’ before ‘}’ token

我对C宏没有太多经验,所以我完全有可能错过一些明显的东西。

2 个答案:

答案 0 :(得分:4)

带注释的行不包含尾随\,因此宏定义会在第一个停止。

答案 1 :(得分:1)

看起来你错过了评论专栏的反斜杠。

相关问题