c++ - Coan 给出了带有定义符号的 "expands to nothing within expression"

标签 c++ c c-preprocessor undefined symbols

我正在尝试使用 coan生成一个干净的代码库版本,但它在第一个定义的第一个源代码上崩溃了,使用:

coan source -DNON_SMS --filter c,h --recurse --replace test -V

我得到:

coan: progress 0x00101: Processing file (1) 
"D:\Documents\Downloads\test\cli.c"
coan: D:\Documents\Downloads\test\cli.c: line 53: error 0x00816: "NON_SMS" expands to nothing within expression, in "#if ( NON_SMS ) /* Non-SMS compile */"
coan: progress 0x02101: Completed with errors, exit code 0x04
coan: info 0x02201: 1 out of 41 input files were reached; 40 files were not reached
coan: info 0x02202: 0 out of 1 files reached were valid; 1 were abandoned due to parse errors

但是代码在 MSVS 上运行正常,这条语句其实很简单:

#if       ( NON_SMS )                   /*  Non-SMS compile  */

#include  <stdlib.h>                    /*  Standard library definitions   */
#include  <string.h>                    /*  String related definitions     */

#else    

这是在 Windows 7 x64 上。

最佳答案

Coan 期望当代码像这样

#if (MACRO)

MACRO 将有一个值——如果您只是想测试宏是否已定义,您可以这样写

#ifdef MACRO

所以你需要给NON_SMS一个值,例如

coan source -DNON_SMS=1 --filter c,h --recurse --replace test -V

关于c++ - Coan 给出了带有定义符号的 "expands to nothing within expression",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40475159/

相关文章:

c - 用 linux/list.h 初始化链表

c - Arduino:检测 while 循环内按下的按钮

c - 如何在 CPP 中串联宏

c - 为什么主要编译器对 stdint.h 使用 typedef 而对 stdbool.h 使用 #define?

c++ - Arduino 上用户控制​​的 SD 卡目录遍历

c++ - 依赖倒置和普遍依赖

C 在定义之前声明结构

c - double-stringize 技巧究竟是如何工作的?

c++ - 从 std::function 创建一个 boost::python::object

c++ - 我们如何插入实时可用的 mongocxx 文档?