1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* Implements the C99 <inttypes.h> interface. */
9 #ifndef mozilla_IntegerPrintfMacros_h_
10 #define mozilla_IntegerPrintfMacros_h_
13 * scanf is a footgun: if the input number exceeds the bounds of the target
14 * type, behavior is undefined (in the compiler sense: that is, this code
15 * could overwrite your hard drive with zeroes):
18 * sscanf("256", "%" SCNu8, &u); // BAD
20 * For this reason, *never* use the SCN* macros provided by this header!
26 * Fix up Android's broken [u]intptr_t inttype macros. Android's PRI*PTR
27 * macros are defined as "ld", but sizeof(long) is 8 and sizeof(intptr_t)
28 * is 4 on 32-bit Android. TestTypeTraits.cpp asserts that these new macro
29 * definitions match the actual type sizes seen at compile time.
31 #if defined(ANDROID) && !defined(__LP64__)
32 # undef PRIdPTR /* intptr_t */
33 # define PRIdPTR "d" /* intptr_t */
34 # undef PRIiPTR /* intptr_t */
35 # define PRIiPTR "i" /* intptr_t */
36 # undef PRIoPTR /* uintptr_t */
37 # define PRIoPTR "o" /* uintptr_t */
38 # undef PRIuPTR /* uintptr_t */
39 # define PRIuPTR "u" /* uintptr_t */
40 # undef PRIxPTR /* uintptr_t */
41 # define PRIxPTR "x" /* uintptr_t */
42 # undef PRIXPTR /* uintptr_t */
43 # define PRIXPTR "X" /* uintptr_t */
46 #endif /* mozilla_IntegerPrintfMacros_h_ */