How to get warnings of incorrect string formatting (C++)

帅比萌擦擦* 提交于 2019-12-03 02:01:07

You can do stuff like this for your own printf-like functions (as well as for scanf/strftime/strfmon-like functions):

#define PRINTF_FORMAT_CHECK(format_index, args_index) __attribute__ ((__format__(printf, format_index, args_index)))

void my_printf(const char *fmt, ...) PRINTF_FORMAT_CHECK(1, 2);

See the gcc manual for further details.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!