From 92a86b9e1b2e9d1278f7990a90f8649111596ea4 Mon Sep 17 00:00:00 2001 From: Pavel P Date: Sun, 1 Jul 2018 21:24:55 -0700 Subject: [PATCH] Compilation fixes for VS2015 - corrected printf modifier for size_t (replaced %lu with %zu) - missing include added (needed by std::min/max) - added static_cast for nullptr to be able to resolve ctor for bytes_ --- butteraugli/butteraugli.cc | 2 +- butteraugli/butteraugli.h | 2 +- butteraugli/butteraugli_main.cc | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/butteraugli/butteraugli.cc b/butteraugli/butteraugli.cc index a9973b1..53e037f 100755 --- a/butteraugli/butteraugli.cc +++ b/butteraugli/butteraugli.cc @@ -107,7 +107,7 @@ static inline void CheckImage(const ImageF &image, const char *name) { const float * const BUTTERAUGLI_RESTRICT row = image.Row(y); for (size_t x = 0; x < image.xsize(); ++x) { if (IsNan(row[x])) { - printf("Image %s @ %lu,%lu (of %lu,%lu)\n", name, x, y, image.xsize(), + printf("Image %s @ %zu,%zu (of %zu,%zu)\n", name, x, y, image.xsize(), image.ysize()); exit(1); } diff --git a/butteraugli/butteraugli.h b/butteraugli/butteraugli.h index 372a4ba..f58c383 100755 --- a/butteraugli/butteraugli.h +++ b/butteraugli/butteraugli.h @@ -216,7 +216,7 @@ class Image { public: using T = ComponentType; - Image() : xsize_(0), ysize_(0), bytes_per_row_(0), bytes_(nullptr, Ignore) {} + Image() : xsize_(0), ysize_(0), bytes_per_row_(0), bytes_(static_cast(nullptr), Ignore) {} Image(const size_t xsize, const size_t ysize) : xsize_(xsize), diff --git a/butteraugli/butteraugli_main.cc b/butteraugli/butteraugli_main.cc index bd8ae09..ad3a538 100755 --- a/butteraugli/butteraugli_main.cc +++ b/butteraugli/butteraugli_main.cc @@ -2,6 +2,7 @@ #include #include #include +#include #include "butteraugli/butteraugli.h" extern "C" { @@ -378,7 +379,7 @@ int Run(int argc, char* argv[]) { // Adding a missing alpha channel to one of the images. rgb2.push_back(Image8(rgb2[0].xsize(), rgb2[0].ysize(), 255)); } else if (rgb1.size() != rgb2.size()) { - fprintf(stderr, "Different number of channels: %lu vs %lu\n", rgb1.size(), + fprintf(stderr, "Different number of channels: %zu vs %zu\n", rgb1.size(), rgb2.size()); exit(1); } @@ -387,7 +388,7 @@ int Run(int argc, char* argv[]) { if (rgb1[c].xsize() != rgb2[c].xsize() || rgb1[c].ysize() != rgb2[c].ysize()) { fprintf( - stderr, "The images are not equal in size: (%lu,%lu) vs (%lu,%lu)\n", + stderr, "The images are not equal in size: (%zu,%zu) vs (%zu,%zu)\n", rgb1[c].xsize(), rgb2[c].xsize(), rgb1[c].ysize(), rgb2[c].ysize()); return 1; } @@ -439,7 +440,7 @@ int Run(int argc, char* argv[]) { return 1; } bool ok = true; - if (fprintf(fmap, "P6\n%lu %lu\n255\n", + if (fprintf(fmap, "P6\n%zu %zu\n255\n", rgb1[0].xsize(), rgb1[0].ysize()) < 0){ perror("fprintf"); ok = false;