GCC warning: ISO C does not permit named variadic macros

前端 未结 1 650
不思量自难忘°
不思量自难忘° 2020-12-20 12:50

Using the following command

gcc -c -Wall -Wextra -pedantic -ansi -std=c99 -fstack-protector-all -fstack-check -O3 root.c -o  rootTESTOBJECT
<
相关标签:
1条回答
  • 2020-12-20 13:24

    #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.)

    0 讨论(0)
提交回复
热议问题