mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
Avoid printf type modifiers not supported by MSVC C runtime library.
The MSVC C library printf() implementation does not support the 'z', 't', 'j', or 'hh' format specifiers. This commit changes the Open vSwitch code to avoid those format specifiers, switching to standard macros from <inttypes.h> where available and inventing new macros resembling them where necessary. It also updates CodingStyle to specify the macros' use and adds a Makefile rule to report violations. Signed-off-by: Alin Serdean <aserdean@cloudbasesolutions.com> Co-authored-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
17
lib/util.h
17
lib/util.h
@@ -212,6 +212,23 @@ is_pow2(uintmax_t x)
|
||||
* (void *). This is to suppress the alignment warning issued by clang. */
|
||||
#define ALIGNED_CAST(TYPE, ATTR) ((TYPE) (void *) (ATTR))
|
||||
|
||||
/* Use "%"PRIuSIZE to format size_t with printf(). */
|
||||
#ifdef _WIN32
|
||||
#define PRIdSIZE "Id"
|
||||
#define PRIiSIZE "Ii"
|
||||
#define PRIoSIZE "Io"
|
||||
#define PRIuSIZE "Iu"
|
||||
#define PRIxSIZE "Ix"
|
||||
#define PRIXSIZE "IX"
|
||||
#else
|
||||
#define PRIdSIZE "zd"
|
||||
#define PRIiSIZE "zi"
|
||||
#define PRIoSIZE "zo"
|
||||
#define PRIuSIZE "zu"
|
||||
#define PRIxSIZE "zx"
|
||||
#define PRIXSIZE "zX"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user