【问题标题】:Error while compiling: expected expression before ')' token编译时出错:')' 标记之前的预期表达式
【发布时间】:2013-01-29 16:14:42
【问题描述】:

这是我程序中的条件之一:

if(Debug)fprintf(stdout,"Direction dir %d quot %d rem %0.2f %s\n",direction,quotient, remain, cardinal[quotient]);

我已经定义了所有内容并使用了stdlib.h,但它不断返回

expected expression before ')' token

我在 ECLIPSE 中使用 minGW 编译器。编译如下:gcc -O0 -g3 -Wall -c -fmessage-length=0 -o wind_direction.o "..\\wind_direction.c"

【问题讨论】:

  • 欢迎来到 SO,请格式化您的代码,并正确标记您的问题。
  • #define 只调试,我猜
  • 试着把它分成几行(这样你就可以知道是if还是fprintf()给了麻烦)。尝试将其减少到大约 5 行代码和标题。尝试从 fprintf() 调用中删除参数。尝试使用-E-P 选项进行编译以获取预处理器输出并查看导致问题的实际文本。

标签: c eclipse mingw c-preprocessor


【解决方案1】:

你可能有:

#define Debug   

With 适合条件编译:

#ifdef Debug
...
#endif

但是 if 需要在 () 里面加上一个表达式。使用,例如:

#define Debug 1

如果你想打印,0 如果你不想。 (但现在使用#if Debug 进行条件编译)

【讨论】:

    猜你喜欢
    • 2018-06-28
    • 1970-01-01
    • 2021-01-30
    • 1970-01-01
    • 2011-03-31
    • 2014-02-22
    • 2015-03-28
    • 2021-02-19
    • 1970-01-01
    相关资源
    最近更新 更多