【问题标题】:What is the flag in the clang compiler to define a macro to be used by the preprocessor?clang 编译器中定义预处理器使用的宏的标志是什么?
【发布时间】:2015-12-23 23:20:54
【问题描述】:

在 gcc 编译器中,我们可以使用 -D 标志(例如-gcc -DN=10 test.c)在 C 中提供一个供预处理器使用的宏

在clang编译器中可以用来做同样事情的标志是什么?

当我在 Windows 上为 clang 编译器提供相同的 -D 选项时,它给出了一个错误:

“找不到目录。”

【问题讨论】:

  • 我在这里找到了一个叫做 -Xpreprocessor 的 clang 选项:clang.llvm.org/docs/CommandGuide/clang.html
  • 也是-D。您应该发布一个测试用例和 clang 版本。 clang test.c 有效还是只有 clang -DN=10 test.c 无效?
  • @Himeshi -Xpreprocessor 不是您要找的。此选项在 clang 中也称为 -D。事实上,POSIX 指定 C 编译器必须为此提供选项 -D

标签: c clang c-preprocessor


【解决方案1】:

答案是上面@cremno 和@FUZxxl 的2 个cmets。

错误不是来自 clang 编译器,尽管它说的是 clang 错误。相反,它来自 Windows cmd,它在“=”符号后查找目录。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-30
    • 1970-01-01
    • 2021-12-29
    • 2014-12-13
    相关资源
    最近更新 更多