I have this simple function, in which I get an error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security].
I know, that I can make a C-style variadic function and use __attribute__((__format__ (__printf__, x, y)))
but I have to keep it in C++ template style.
Are there any workarounds for this problem? I tried: printf("%s", boost::str((boost::format(inputString) % ... % args)).c_str());
, but It doesn't work the same as printf.
template <typename... Types>
inline static void log(const char* inputString, Types... args)
{
printf(inputString, args...);
}
Aucun commentaire:
Enregistrer un commentaire