acl/lib_acl_cpp/include/acl_cpp/stdlib/snprintf.hpp

38 lines
1.6 KiB
C++
Raw Normal View History

#pragma once
2017-06-02 14:47:24 +08:00
#include "../acl_cpp_define.hpp"
2014-11-19 00:25:21 +08:00
#include <stdarg.h>
namespace acl {
/**
* C snprintf API '\0'
* @param buf {char*}
* @param size {size_t} buf
* @param fmt {const char*}
* @return {int} :
* 1) UNIX/LINUX
* >= size _WIN32
* 2) _WIN32 -1
*/
#if defined(__GNUC__) && (__GNUC__ > 4 ||(__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
ACL_CPP_API int ACL_CPP_PRINTF(3, 4) safe_snprintf(char *buf, size_t size,
const char *fmt, ...);
#else
ACL_CPP_API int safe_snprintf(char *buf, size_t size, const char *fmt, ...);
#endif
2014-11-19 00:25:21 +08:00
/**
* C snprintf API '\0'
* @param buf {char*}
* @param size {size_t} buf
* @param fmt {const char*}
* @param ap {va_list}
* @return {int} :
* 1) UNIX/LINUX
* >= size _WIN32
* 2) _WIN32 -1
*/
ACL_CPP_API int safe_vsnprintf(char *buf, size_t size, const char *fmt, va_list ap);
2014-11-19 00:25:21 +08:00
} // namespace acl