Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(624)

Side by Side Diff: base/format_macros.h

Issue 1141793003: Update from https://crrev.com/329939 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/files/file_win.cc ('k') | base/i18n/icu_string_conversions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_FORMAT_MACROS_H_ 5 #ifndef BASE_FORMAT_MACROS_H_
6 #define BASE_FORMAT_MACROS_H_ 6 #define BASE_FORMAT_MACROS_H_
7 7
8 // This file defines the format macros for some integer types. 8 // This file defines the format macros for some integer types.
9 9
10 // To print a 64-bit value in a portable way: 10 // To print a 64-bit value in a portable way:
11 // int64_t value; 11 // int64_t value;
12 // printf("xyz:%" PRId64, value); 12 // printf("xyz:%" PRId64, value);
13 // The "d" in the macro corresponds to %d; you can also use PRIu64 etc. 13 // The "d" in the macro corresponds to %d; you can also use PRIu64 etc.
14 // 14 //
15 // For wide strings, prepend "Wide" to the macro: 15 // For wide strings, prepend "Wide" to the macro:
16 // int64_t value; 16 // int64_t value;
17 // StringPrintf(L"xyz: %" WidePRId64, value); 17 // StringPrintf(L"xyz: %" WidePRId64, value);
18 // 18 //
19 // To print a size_t value in a portable way: 19 // To print a size_t value in a portable way:
20 // size_t size; 20 // size_t size;
21 // printf("xyz: %" PRIuS, size); 21 // printf("xyz: %" PRIuS, size);
22 // The "u" in the macro corresponds to %u, and S is for "size". 22 // The "u" in the macro corresponds to %u, and S is for "size".
23 23
24 #include "build/build_config.h" 24 #include "build/build_config.h"
25 25
26 #if defined(OS_POSIX) 26 #if defined(OS_POSIX) && (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && \
27 27 !defined(PRId64)
28 #if (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && !defined(PRId64)
29 #error "inttypes.h has already been included before this header file, but " 28 #error "inttypes.h has already been included before this header file, but "
30 #error "without __STDC_FORMAT_MACROS defined." 29 #error "without __STDC_FORMAT_MACROS defined."
31 #endif 30 #endif
32 31
33 #if !defined(__STDC_FORMAT_MACROS) 32 #if defined(OS_POSIX) && !defined(__STDC_FORMAT_MACROS)
34 #define __STDC_FORMAT_MACROS 33 #define __STDC_FORMAT_MACROS
35 #endif 34 #endif
36 35
37 #include <inttypes.h> 36 #include <inttypes.h>
38 37
38 #if defined(OS_POSIX)
39
39 // GCC will concatenate wide and narrow strings correctly, so nothing needs to 40 // GCC will concatenate wide and narrow strings correctly, so nothing needs to
40 // be done here. 41 // be done here.
41 #define WidePRId64 PRId64 42 #define WidePRId64 PRId64
42 #define WidePRIu64 PRIu64 43 #define WidePRIu64 PRIu64
43 #define WidePRIx64 PRIx64 44 #define WidePRIx64 PRIx64
44 45
45 #if !defined(PRIuS) 46 #if !defined(PRIuS)
46 #define PRIuS "zu" 47 #define PRIuS "zu"
47 #endif 48 #endif
48 49
(...skipping 20 matching lines...) Expand all
69 #define PRIuNS "u" 70 #define PRIuNS "u"
70 #endif 71 #endif
71 #if !defined(PRIxNS) 72 #if !defined(PRIxNS)
72 #define PRIxNS "x" 73 #define PRIxNS "x"
73 #endif 74 #endif
74 #endif 75 #endif
75 #endif // defined(OS_MACOSX) 76 #endif // defined(OS_MACOSX)
76 77
77 #else // OS_WIN 78 #else // OS_WIN
78 79
79 #if !defined(PRId64) 80 #if !defined(PRId64) || !defined(PRIu64) || !defined(PRIx64)
80 #define PRId64 "I64d" 81 #error "inttypes.h provided by win toolchain should define these."
81 #endif
82
83 #if !defined(PRIu64)
84 #define PRIu64 "I64u"
85 #endif
86
87 #if !defined(PRIx64)
88 #define PRIx64 "I64x"
89 #endif 82 #endif
90 83
91 #define WidePRId64 L"I64d" 84 #define WidePRId64 L"I64d"
92 #define WidePRIu64 L"I64u" 85 #define WidePRIu64 L"I64u"
93 #define WidePRIx64 L"I64x" 86 #define WidePRIx64 L"I64x"
94 87
95 #if !defined(PRIuS) 88 #if !defined(PRIuS)
96 #define PRIuS "Iu" 89 #define PRIuS "Iu"
97 #endif 90 #endif
98 91
99 #endif 92 #endif
100 93
101 #endif // BASE_FORMAT_MACROS_H_ 94 #endif // BASE_FORMAT_MACROS_H_
OLDNEW
« no previous file with comments | « base/files/file_win.cc ('k') | base/i18n/icu_string_conversions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698