GCC warning: ISO C does not permit named variadic macros

匆匆过客 提交于 2019-11-29 13:39:58

#define crumb(phrase0...) <whatever> is giving a name (phrase0) to the variable arguments (...).

This is a GCC extension.

C99 does define a way of passing variable arguments to macros (see §6.10.3/12 and §6.10.3.1/2): the variable arguments are unnamed on the left-hand side of the definitions (i.e. just ...), and referenced on the right-hand side as __VA_ARGS__, like this:

#define crumb(...) printf(__VA_ARGS__)

(By the way, your gcc arguments should not include both -ansi and -std=c99: -ansi specifies the earlier C standard (known variously as ANSI C, C89 or C90); the combination of both options only happens to select C99 in this case because -std=c99 appears after -ansi in the argument list, and the last one wins.)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!