[M85 Dev][EFL] Fix crashes at webview launch
[platform/framework/web/chromium-efl.git] / base / format_macros.h
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.
4
5 #ifndef BASE_FORMAT_MACROS_H_
6 #define BASE_FORMAT_MACROS_H_
7
8 // This file defines the format macros for some integer types.
9
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.
14 //
15 // For wide strings, prepend "Wide" to the macro:
16 //   int64_t value;
17 //   StringPrintf(L"xyz: %" WidePRId64, value);
18 //
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".
23
24 #include <stddef.h>
25 #include <stdint.h>
26
27 #include "build/build_config.h"
28
29 #if (defined(OS_POSIX) || defined(OS_FUCHSIA)) && \
30     (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && !defined(PRId64)
31 #error "inttypes.h has already been included before this header file, but "
32 #error "without __STDC_FORMAT_MACROS defined."
33 #endif
34
35 #if (defined(OS_POSIX) || defined(OS_FUCHSIA)) && !defined(__STDC_FORMAT_MACROS)
36 #define __STDC_FORMAT_MACROS
37 #endif
38
39 #include <inttypes.h>
40
41 #if defined(OS_WIN)
42
43 #if !defined(PRId64) || !defined(PRIu64) || !defined(PRIx64)
44 #error "inttypes.h provided by win toolchain should define these."
45 #endif
46
47 #define WidePRId64 L"I64d"
48 #define WidePRIu64 L"I64u"
49 #define WidePRIx64 L"I64x"
50
51 #if !defined(PRIuS)
52 #define PRIuS "Iu"
53 #endif
54
55 #elif defined(OS_POSIX) || defined(OS_FUCHSIA)
56
57 // GCC will concatenate wide and narrow strings correctly, so nothing needs to
58 // be done here.
59 #define WidePRId64 PRId64
60 #define WidePRIu64 PRIu64
61 #define WidePRIx64 PRIx64
62
63 #if !defined(PRIuS)
64 #define PRIuS "zu"
65 #endif
66
67 #endif  // defined(OS_WIN)
68
69 // The size of NSInteger and NSUInteger varies between 32-bit and 64-bit
70 // architectures and Apple does not provides standard format macros and
71 // recommends casting. This has many drawbacks, so instead define macros
72 // for formatting those types.
73 #if defined(OS_MACOSX)
74 #if defined(ARCH_CPU_64_BITS)
75 #if !defined(PRIdNS)
76 #define PRIdNS "ld"
77 #endif
78 #if !defined(PRIuNS)
79 #define PRIuNS "lu"
80 #endif
81 #if !defined(PRIxNS)
82 #define PRIxNS "lx"
83 #endif
84 #else  // defined(ARCH_CPU_64_BITS)
85 #if !defined(PRIdNS)
86 #define PRIdNS "d"
87 #endif
88 #if !defined(PRIuNS)
89 #define PRIuNS "u"
90 #endif
91 #if !defined(PRIxNS)
92 #define PRIxNS "x"
93 #endif
94 #endif
95 #endif  // defined(OS_MACOSX)
96
97 #endif  // BASE_FORMAT_MACROS_H_