summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Dawson <brucedawson@google.com>2014-11-18 13:42:28 -0800
committerBruce Dawson <brucedawson@google.com>2014-11-18 13:42:28 -0800
commitddc206276c96406b47f9c8760e981500d7ad9063 (patch)
treefb7f53eb9e45b03c39b3e5f26cf3704f75d7b555
parent0ed3b28a70c64e06340b892e6b5e753f80b0fa4e (diff)
downloadpdfium-ddc206276c96406b47f9c8760e981500d7ad9063.tar.xz
Merge to XFA: patch from CL 738433003
Review URL: https://codereview.chromium.org/738433003 R=tsepez@chromium.org TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/741473003
-rw-r--r--core/include/fxcrt/fx_system.h31
-rw-r--r--samples/pdfium_test.cc5
2 files changed, 34 insertions, 2 deletions
diff --git a/core/include/fxcrt/fx_system.h b/core/include/fxcrt/fx_system.h
index 36050f35dc..355bd74327 100644
--- a/core/include/fxcrt/fx_system.h
+++ b/core/include/fxcrt/fx_system.h
@@ -293,4 +293,35 @@ typedef base::CheckedNumeric<size_t> FX_SAFE_SIZE_T;
#define FX_OVERRIDE
#endif
#endif
+
+// To print a size_t value in a portable way:
+// size_t size;
+// printf("xyz: %" PRIuS, size);
+// The "u" in the macro corresponds to %u, and S is for "size".
+
+#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
+
+#if (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && !defined(PRId64)
+#error "inttypes.h has already been included before this header file, but "
+#error "without __STDC_FORMAT_MACROS defined."
+#endif
+
+#if !defined(__STDC_FORMAT_MACROS)
+#define __STDC_FORMAT_MACROS
+#endif
+
+#include <inttypes.h>
+
+#if !defined(PRIuS)
+#define PRIuS "zu"
+#endif
+
+#else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+
+#if !defined(PRIuS)
+#define PRIuS "Iu"
+#endif
+
+#endif
+
#endif
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index f50d4d16a2..3c0cef4dbf 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -16,6 +16,7 @@
#include "../fpdfsdk/include/fpdfformfill.h"
#include "../fpdfsdk/include/fpdftext.h"
#include "../fpdfsdk/include/fpdfview.h"
+#include "../core/include/fxcrt/fx_system.h"
#include "v8/include/v8.h"
#ifdef _WIN32
@@ -360,8 +361,8 @@ void RenderPdf(const char* name, const char* pBuf, size_t len,
FPDFDOC_ExitFormFillEnvironment(form);
FPDFAvail_Destroy(pdf_avail);
- printf("Loaded, parsed and rendered %zu pages.\n", rendered_pages);
- printf("Skipped %zu bad pages.\n", bad_pages);
+ printf("Loaded, parsed and rendered %" PRIuS " pages.\n", rendered_pages);
+ printf("Skipped %" PRIuS " bad pages.\n", bad_pages);
}
int main(int argc, const char* argv[]) {