WPILibC++ 2027.0.0-alpha-3
Loading...
Searching...
No Matches
vsnprintf_compat.h
Go to the documentation of this file.
1// Protocol Buffers - Google's data interchange format
2// Copyright 2023 Google LLC. All rights reserved.
3//
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file or at
6// https://developers.google.com/open-source/licenses/bsd
7
8#ifndef UPB_PORT_VSNPRINTF_COMPAT_H_
9#define UPB_PORT_VSNPRINTF_COMPAT_H_
10
11// Must be last.
12#include "upb/port/def.inc"
13
14UPB_INLINE int _upb_vsnprintf(char* buf, size_t size, const char* fmt,
15 va_list ap) {
16#if defined(__MINGW64__) || defined(__MINGW32__) || defined(_MSC_VER)
17 // The msvc runtime has a non-conforming vsnprintf() that requires the
18 // following compatibility code to become conformant.
19 int n = -1;
20 if (size != 0) n = _vsnprintf_s(buf, size, _TRUNCATE, fmt, ap);
21 if (n == -1) n = _vscprintf(fmt, ap);
22 return n;
23#else
24 return vsnprintf(buf, size, fmt, ap);
25#endif
26}
27
28#include "upb/port/undef.inc"
29
30#endif // UPB_PORT_VSNPRINTF_COMPAT_H_
#define UPB_INLINE
Definition def.inc:144
UPB_INLINE int _upb_vsnprintf(char *buf, size_t size, const char *fmt, va_list ap)
Definition vsnprintf_compat.h:14