diff --git a/include/aidge/utils/Formatting.hpp b/include/aidge/utils/Formatting.hpp index 8f572a86743004fe34395ddb6559ac36b5dc6634..e96e87e35eb246a35f129b4317fe8d80e55df142 100644 --- a/include/aidge/utils/Formatting.hpp +++ b/include/aidge/utils/Formatting.hpp @@ -20,12 +20,16 @@ namespace Aidge { // The code snippet below is licensed under CC0 1.0. template<typename ... Args> std::string stringFormat(const std::string& format, Args... args) { +#if defined(__clang__) +#elif defined(__GNUC__) || defined(__GNUG__) // Disable security warning on GCC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-security" +#elif defined(_MSC_VER) // Disable security warning on MSVC #pragma warning(push) #pragma warning(disable : 4774) +#endif int size_s = std::snprintf(nullptr, 0, format.c_str(), args...) + 1; // Extra space for '\0' if (size_s <= 0) { std::printf("Error during formatting."); @@ -35,8 +39,12 @@ std::string stringFormat(const std::string& format, Args... args) { std::unique_ptr<char[]> buf(new char[size]); std::snprintf(buf.get(), size, format.c_str(), args...); return std::string(buf.get(), buf.get() + size - 1); // We don't want the '\0' inside -#pragma warning(pop) +#if defined(__clang__) +#elif defined(__GNUC__) || defined(__GNUG__) #pragma GCC diagnostic pop +#elif defined(_MSC_VER) +#pragma warning(pop) +#endif } /**