Is it possible to un-const typeof in gcc pure C?

后端 未结 5 1241
误落风尘
误落风尘 2021-02-19 14:42

I have a macro that uses GCC\'s typeof to create a variable of the same type of a macro argument. The problem is: if that argument has const type, the variable crea

5条回答
  •  迷失自我
    2021-02-19 15:42

    Is it possible to un-const typeof in gcc pure C?

    I don't thing so, but this will work:

    #define DECR(x) __extension__({__typeof__(x) y = x - 1; y;})
    

    Note that __extension__ is used for disable ISO C forbids braced-groups within expressions[-pedantic] warning.

提交回复
热议问题