File indexing completed on 2025-01-18 09:52:35
0001 #ifndef BOOST_SYSTEM_DETAIL_SNPRINTF_HPP_INCLUDED
0002 #define BOOST_SYSTEM_DETAIL_SNPRINTF_HPP_INCLUDED
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <boost/config.hpp>
0012 #include <cstdio>
0013 #include <cstdarg>
0014
0015
0016
0017 namespace boost
0018 {
0019
0020 namespace system
0021 {
0022
0023 namespace detail
0024 {
0025
0026 #if ( defined(_MSC_VER) && _MSC_VER < 1900 ) || ( defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) )
0027
0028 inline void snprintf( char * buffer, std::size_t len, char const * format, ... )
0029 {
0030 # if defined( BOOST_MSVC )
0031 # pragma warning( push )
0032 # pragma warning( disable: 4996 )
0033 # endif
0034
0035 if( len == 0 ) return;
0036
0037 va_list args;
0038 va_start( args, format );
0039
0040 _vsnprintf( buffer, len - 1, format, args );
0041 buffer[ len - 1 ] = 0;
0042
0043 va_end( args );
0044
0045 # if defined( BOOST_MSVC )
0046 # pragma warning( pop )
0047 # endif
0048 }
0049
0050 #else
0051
0052 #if defined(__GNUC__) && __GNUC__ >= 3
0053 __attribute__((__format__ (__printf__, 3, 4)))
0054 #endif
0055 inline void snprintf( char * buffer, std::size_t len, char const * format, ... )
0056 {
0057 va_list args;
0058 va_start( args, format );
0059
0060 std::vsnprintf( buffer, len, format, args );
0061
0062 va_end( args );
0063 }
0064
0065 #endif
0066
0067 }
0068
0069 }
0070
0071 }
0072
0073 #endif