OLD | NEW |
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 <stddef.h> |
| 25 #include <stdint.h> |
| 26 |
24 #include "build/build_config.h" | 27 #include "build/build_config.h" |
25 | 28 |
26 #if defined(OS_POSIX) && (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && \ | 29 #if defined(OS_POSIX) && (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && \ |
27 !defined(PRId64) | 30 !defined(PRId64) |
28 #error "inttypes.h has already been included before this header file, but " | 31 #error "inttypes.h has already been included before this header file, but " |
29 #error "without __STDC_FORMAT_MACROS defined." | 32 #error "without __STDC_FORMAT_MACROS defined." |
30 #endif | 33 #endif |
31 | 34 |
32 #if defined(OS_POSIX) && !defined(__STDC_FORMAT_MACROS) | 35 #if defined(OS_POSIX) && !defined(__STDC_FORMAT_MACROS) |
33 #define __STDC_FORMAT_MACROS | 36 #define __STDC_FORMAT_MACROS |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 #define WidePRIu64 L"I64u" | 88 #define WidePRIu64 L"I64u" |
86 #define WidePRIx64 L"I64x" | 89 #define WidePRIx64 L"I64x" |
87 | 90 |
88 #if !defined(PRIuS) | 91 #if !defined(PRIuS) |
89 #define PRIuS "Iu" | 92 #define PRIuS "Iu" |
90 #endif | 93 #endif |
91 | 94 |
92 #endif | 95 #endif |
93 | 96 |
94 #endif // BASE_FORMAT_MACROS_H_ | 97 #endif // BASE_FORMAT_MACROS_H_ |
OLD | NEW |