1 /*
2  *  Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef RTC_BASE_FORMAT_MACROS_H_
12 #define RTC_BASE_FORMAT_MACROS_H_
13 
14 // This file defines the format macros for some integer types and is derived
15 // from Chromium's base/format_macros.h.
16 
17 // To print a 64-bit value in a portable way:
18 //   int64_t value;
19 //   printf("xyz:%" PRId64, value);
20 // The "d" in the macro corresponds to %d; you can also use PRIu64 etc.
21 //
22 // To print a size_t value in a portable way:
23 //   size_t size;
24 //   printf("xyz: %" RTC_PRIuS, size);
25 // The "u" in the macro corresponds to %u, and S is for "size".
26 
27 #if defined(WEBRTC_POSIX)
28 
29 #if (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && !defined(PRId64)
30 #error "inttypes.h has already been included before this header file, but "
31 #error "without __STDC_FORMAT_MACROS defined."
32 #endif
33 
34 #if !defined(__STDC_FORMAT_MACROS)
35 #define __STDC_FORMAT_MACROS
36 #endif
37 
38 #include <inttypes.h>
39 
40 #include "rtc_base/system/arch.h"
41 
42 #define RTC_PRIuS "zu"
43 
44 #else  // WEBRTC_WIN
45 
46 #include <inttypes.h>
47 
48 #if !defined(PRId64) || !defined(PRIu64) || !defined(PRIx64)
49 #error "inttypes.h provided by win toolchain should define these."
50 #endif
51 
52 // PRI*64 were added in MSVC 2013, while "%zu" is supported since MSVC 2015
53 // (so needs to be special-cased to "%Iu" instead).
54 
55 #define RTC_PRIuS "Iu"
56 
57 #endif
58 
59 #endif  // RTC_BASE_FORMAT_MACROS_H_
60