How should I properly use __attribute__ ((format (printf, x, y))) inside a class method in C++?

后端 未结 4 435
长发绾君心
长发绾君心 2021-01-01 10:20

I\'m trying to define a class method for debug prints that will behave like printf:

inline void debug(const char* fmt, ...) __attribute__ ((form         


        
4条回答
  •  情书的邮戳
    2021-01-01 10:41

    Since it only works for gcc, it would be good to define it this way to avoid errors on other compilers.

    #ifdef __GNUC__
              __attribute__ (( format( printf, 2, 3 ) ))
    #endif
    

提交回复
热议问题