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
3 // found in the LICENSE file.
5 #ifndef BASE_FORMAT_MACROS_H_
6 #define BASE_FORMAT_MACROS_H_
9 // This file defines the format macros for some integer types.
11 // To print a 64-bit value in a portable way:
13 // printf("xyz:%" PRId64, value);
14 // The "d" in the macro corresponds to %d; you can also use PRIu64 etc.
16 // For wide strings, prepend "Wide" to the macro:
18 // StringPrintf(L"xyz: %" WidePRId64, value);
20 // To print a size_t value in a portable way:
22 // printf("xyz: %" PRIuS, size);
23 // The "u" in the macro corresponds to %u, and S is for "size".
25 #include "build/build_config.h"
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."
34 #if !defined(__STDC_FORMAT_MACROS)
35 #define __STDC_FORMAT_MACROS
40 // GCC will concatenate wide and narrow strings correctly, so nothing needs to
42 #define WidePRId64 PRId64
43 #define WidePRIu64 PRIu64
44 #define WidePRIx64 PRIx64
64 #define WidePRId64 L"I64d"
65 #define WidePRIu64 L"I64u"
66 #define WidePRIx64 L"I64x"
74 #endif // BASE_FORMAT_MACROS_H_