canesin canesin - 3 months ago 36
C Question

Coan gives "expands to nothing within expression" with defined symbol

I am trying to use coan to generate a clean version of a codebase but it creashes on the first source code fine on the first definition, using:

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

I get:

coan: progress 0x00101: Processing file (1)
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

but the code works properly on MSVS and this statement is actually very simple:

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

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


This is on Windows 7 x64.


Coan expects that when the code is like

#if (MACRO)

that MACRO will have a value -- if you just wanted to test whether the macro is defined, you would have written

#ifdef MACRO

So you need to give NON_SMS a value, e.g.

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