Encode method and error message inside LevelDB::Status message
[chromium-blink-merge.git] / base / format_macros.h
blob466d79be731bf5d8c2e4f57c5c1109d5d985b612
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_
8 // This file defines the format macros for some integer types.
10 // To print a 64-bit value in a portable way:
11 // int64_t value;
12 // printf("xyz:%" PRId64, value);
13 // The "d" in the macro corresponds to %d; you can also use PRIu64 etc.
15 // For wide strings, prepend "Wide" to the macro:
16 // int64_t value;
17 // StringPrintf(L"xyz: %" WidePRId64, value);
19 // To print a size_t value in a portable way:
20 // size_t size;
21 // printf("xyz: %" PRIuS, size);
22 // The "u" in the macro corresponds to %u, and S is for "size".
24 #include "build/build_config.h"
26 #if defined(OS_POSIX)
28 #if (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && !defined(PRId64)
29 #error "inttypes.h has already been included before this header file, but "
30 #error "without __STDC_FORMAT_MACROS defined."
31 #endif
33 #if !defined(__STDC_FORMAT_MACROS)
34 #define __STDC_FORMAT_MACROS
35 #endif
37 #include <inttypes.h>
39 // GCC will concatenate wide and narrow strings correctly, so nothing needs to
40 // be done here.
41 #define WidePRId64 PRId64
42 #define WidePRIu64 PRIu64
43 #define WidePRIx64 PRIx64
45 #if !defined(PRIuS)
46 #define PRIuS "zu"
47 #endif
49 #else // OS_WIN
51 #if !defined(PRId64)
52 #define PRId64 "I64d"
53 #endif
55 #if !defined(PRIu64)
56 #define PRIu64 "I64u"
57 #endif
59 #if !defined(PRIx64)
60 #define PRIx64 "I64x"
61 #endif
63 #define WidePRId64 L"I64d"
64 #define WidePRIu64 L"I64u"
65 #define WidePRIx64 L"I64x"
67 #if !defined(PRIuS)
68 #define PRIuS "Iu"
69 #endif
71 #endif
73 #endif // BASE_FORMAT_MACROS_H_