Is __COUNTER__ macro portable?

前端 未结 3 1247
南方客
南方客 2021-01-13 01:10

I have a piece of code which uses __COUNTER__ macro to generate unique names for variables.

Is this code portable ? I know that GCC and MSVS support it.

3条回答
  •  旧时难觅i
    2021-01-13 01:40

    GCC manual, section Common Predefined Macros, states

    The common predefined macros are GNU C extensions.

    I've also never seen this macro in the C99, C11 or C++11 standards.

    As for practical portability: Clang supports it, too.

提交回复
热议问题