【问题标题】:Clang gives confusing error message "expected value in expression"Clang 给出了令人困惑的错误消息“表达式中的预期值”
【发布时间】:2021-06-22 15:34:09
【问题描述】:

我从 Clang 10 收到以下错误消息:

error: expected value in expression
#if FOOBAR
          ^
1 error generated.

没有更多信息。这可能是什么原因?

【问题讨论】:

  • 也许你想要#ifdef? #if 期待一个表达式。
  • FOOBAR 是如何定义的? (或者它被定义了吗?)你能提供一个minimal reproducible example吗?
  • 请提供正确的minimal reproducible example。
  • I got the error 在行前添加#define FOOBAR。
  • 该错误不在我的代码中,因此我无法生成可重现的示例,因为我不明白。

标签: c clang c-preprocessor


【解决方案1】:

这可能是什么原因?

当宏被定义为空时

#define FOOBAR

然后

#if FOOBAR

扩展为:

#if

编译器会打印一个错误 - if 需要一个表达式 #if something-here。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-24
    • 2022-11-22
    • 1970-01-01
    相关资源
    最近更新 更多