emilib
strprintf.hpp
1 // By Emil Ernerfeldt 2014-2016
2 // LICENSE:
3 // This software is dual-licensed to the public domain and under the following
4 // license: you are granted a perpetual, irrevocable license to copy, modify,
5 // publish, and distribute this file as you see fit.
6 // HISTORY:
7 // Created in 2014 for Ghostel
8 // Moved into emilib in 2016
9 
10 #pragma once
11 
12 #include <string>
13 
14 namespace emilib {
15 
16 // strprintf acts like printf, but writes to a std::string.
17 
18 // Try to catch format string errors at compile time with compiler-specific extensions:
19 #ifdef _MSC_VER
20  std::string strprintfv(_In_z_ _Printf_format_string_ const char* format, va_list);
21  std::string strprintf(_In_z_ _Printf_format_string_ const char* format, ...);
22 #elif defined(__clang__) || defined(__GNUC__)
23  std::string strprintfv(const char* format, va_list) __attribute__((format(printf, 1, 0)));
24  std::string strprintf(const char* format, ...) __attribute__((format(printf, 1, 2)));
25 #else
26  std::string strprintfv(const char* format, va_list);
27  std::string strprintf(const char* format, ...);
28 #endif
29 
30 } // namespace emilib
Definition: coroutine.hpp:18