fails to expand inner macro with a parameter that contains a ","
Closed this issue · 0 comments
danmar commented
Example code:
#define Z_IS_ENABLED1(config_macro) Z_IS_ENABLED2(_XXXX##config_macro)
#define _XXXX1 _YYYY,
#define Z_IS_ENABLED2(one_or_two_args) Z_IS_ENABLED3(one_or_two_args 1, 0)
#define Z_IS_ENABLED3(ignore_this, val, ...) val
#define IS_ENABLED(config_macro) Z_IS_ENABLED1(config_macro)
#define CONFIG_SYS_HEAP_SMALL_ONLY 1
a = IS_ENABLED(CONFIG_SYS_HEAP_SMALL_ONLY)
gcc output:
$ gcc -E 1.c
# 0 "1.c"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 0 "<command-line>" 2
# 1 "1.c"
# 10 "1.c"
a = 1
simplecpp output:
simplecpp 1.c
1.c:1: syntax error: failed to expand 'IS_ENABLED', Wrong number of parameters for macro 'Z_IS_ENABLED2'.