14591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org/*
24591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org *  Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
34591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org *
44591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org *  Use of this source code is governed by a BSD-style license
54591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org *  that can be found in the LICENSE file in the root of the source
64591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org *  tree. An additional intellectual property rights grant can be found
74591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org *  in the file PATENTS.  All contributing project authors may
84591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org *  be found in the AUTHORS file in the root of the source tree.
94591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org */
104591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org
114591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#ifndef WEBRTC_BASE_FORMAT_MACROS_H_
124591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#define WEBRTC_BASE_FORMAT_MACROS_H_
134591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org
144591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org// This file defines the format macros for some integer types and is derived
154591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org// from Chromium's base/format_macros.h.
164591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org
174591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org// To print a 64-bit value in a portable way:
184591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org//   int64_t value;
194591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org//   printf("xyz:%" PRId64, value);
204591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org// The "d" in the macro corresponds to %d; you can also use PRIu64 etc.
214591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org//
224591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org// To print a size_t value in a portable way:
234591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org//   size_t size;
244591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org//   printf("xyz: %" PRIuS, size);
254591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org// The "u" in the macro corresponds to %u, and S is for "size".
264591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org
274591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#include "webrtc/typedefs.h"
284591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org
294591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#if defined(WEBRTC_POSIX)
304591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org
314591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#if (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && !defined(PRId64)
324591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#error "inttypes.h has already been included before this header file, but "
334591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#error "without __STDC_FORMAT_MACROS defined."
344591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#endif
354591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org
364591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#if !defined(__STDC_FORMAT_MACROS)
374591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#define __STDC_FORMAT_MACROS
384591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#endif
394591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org
404591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#include <inttypes.h>
414591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org
424591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#if !defined(PRIuS)
434591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#define PRIuS "zu"
444591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#endif
454591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org
464591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org// The size of NSInteger and NSUInteger varies between 32-bit and 64-bit
474591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org// architectures and Apple does not provides standard format macros and
484591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org// recommends casting. This has many drawbacks, so instead define macros
494591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org// for formatting those types.
504591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#if defined(WEBRTC_MAC)
514591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#if defined(WEBRTC_ARCH_64_BITS)
524591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#if !defined(PRIdNS)
534591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#define PRIdNS "ld"
544591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#endif
554591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#if !defined(PRIuNS)
564591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#define PRIuNS "lu"
574591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#endif
584591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#if !defined(PRIxNS)
594591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#define PRIxNS "lx"
604591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#endif
614591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#else  // defined(WEBRTC_ARCH_64_BITS)
624591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#if !defined(PRIdNS)
634591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#define PRIdNS "d"
644591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#endif
654591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#if !defined(PRIuNS)
664591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#define PRIuNS "u"
674591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#endif
684591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#if !defined(PRIxNS)
694591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#define PRIxNS "x"
704591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#endif
714591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#endif
724591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#endif  // defined(WEBRTC_MAC)
734591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org
744591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#else  // WEBRTC_WIN
754591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org
76f888bb58da04c5095759b5ec7ce2e1fa2cd414fdTommi#include <inttypes.h>
77f888bb58da04c5095759b5ec7ce2e1fa2cd414fdTommi
784591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#if !defined(PRId64)
794591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#define PRId64 "I64d"
804591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#endif
814591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org
824591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#if !defined(PRIu64)
834591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#define PRIu64 "I64u"
844591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#endif
854591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org
864591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#if !defined(PRIx64)
874591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#define PRIx64 "I64x"
884591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#endif
894591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org
904591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#if !defined(PRIuS)
914591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#define PRIuS "Iu"
924591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#endif
934591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org
944591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#endif
954591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org
964591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#endif  // WEBRTC_BASE_FORMAT_MACROS_H_
97