__attribute__((format(printf, 1, 2))) for MSVC?

后端 未结 4 1785
半阙折子戏
半阙折子戏 2020-12-03 17:01

With GCC, I can specify __attribute__((format(printf, 1, 2))) , telling the compiler that this function takes vararg parameters that are printf format specifie

4条回答
  •  星月不相逢
    2020-12-03 17:50

    While GCC checks format specifiers when -Wformat is enabled, VC++ has no such checking, even for standard functions so there is no equivalent to this __attribute__ because there is no equivalent to -Wformat.

    I think Microsoft's emphasis on C++ (evidenced by maintaining ISO compliance for C++ while only supporting C89) may be in part the reason why VC++ does not have format specifier checking; in C++ using format specifiers are unnecessary.

提交回复
热议问题