Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Compilation fixes for VS2015 #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion butteraugli/butteraugli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion butteraugli/butteraugli.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t*>(nullptr), Ignore) {}
Copy link
Author

@pps83 pps83 Jul 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no idea why VS doesn't compile it. Without this fix it fails with this error:

1>c:\butteraugli\butteraugli.h(219): error C2661: 'std::unique_ptr<uint8_t [],void (__cdecl *)(void *)>::unique_ptr': no overloaded function takes 2 arguments
1>  c:\butteraugli\butteraugli.h(219): note: while compiling class template member function 'butteraugli::Image<float>::Image(void)'
1>  c:\butteraugli\butteraugli.cc(1839): note: see reference to function template instantiation 'butteraugli::Image<float>::Image(void)' being compiled
1>  c:\butteraugli\butteraugli.cc(106): note: see reference to class template instantiation 'butteraugli::Image<float>' being compiled

Also it seems that vs2017 doesn't have that problem.


Image(const size_t xsize, const size_t ysize)
: xsize_(xsize),
Expand Down
7 changes: 4 additions & 3 deletions butteraugli/butteraugli_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <cstdint>
#include <cstdio>
#include <vector>
#include <algorithm>
#include "butteraugli/butteraugli.h"

extern "C" {
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down