glassechidna / zxing-cpp

ZXing C++ Library
Apache License 2.0
610 stars 435 forks source link

Fix for compilation errors when using zxing-cpp #53

Closed wrapperband closed 7 years ago

wrapperband commented 7 years ago

In the class LuminanceSource line 30 has been edited to public variable from private. To fix compile errors with some OSs.

aidansteele commented 7 years ago

Out of interest which OSes are affected? It'd be nice to add them to the test suite so we don't accidentally break them again in the future.

natedavis commented 7 years ago

I am getting this error when I try and compile on Mac OS X - Specifically for a cryptocurrency wallet.

qimagesource.cpp:19:29: error: 'width' is a private member of 'zxing::LuminanceSource'
    ArrayRef<char> mymatrix(width*height);
                            ^
/usr/local/include/zxing/LuminanceSource.h:31:13: note: declared private here
  const int width;
            ^
qimagesource.cpp:19:35: error: 'height' is a private member of 'zxing::LuminanceSource'
    ArrayRef<char> mymatrix(width*height);
                                  ^
/usr/local/include/zxing/LuminanceSource.h:32:13: note: declared private here
  const int height;
            ^
qimagesource.cpp:20:25: error: 'height' is a private member of 'zxing::LuminanceSource'
    for (int y = 0; y < height; y++)
                        ^
/usr/local/include/zxing/LuminanceSource.h:32:13: note: declared private here
  const int height;
            ^
qimagesource.cpp:22:29: error: 'width' is a private member of 'zxing::LuminanceSource'
        for (int x = 0; x < width; x++) {
                            ^
/usr/local/include/zxing/LuminanceSource.h:31:13: note: declared private here
  const int width;
            ^
qimagesource.cpp:23:24: error: 'width' is a private member of 'zxing::LuminanceSource'
            mymatrix[y*width+x] = qGray(image.pixel(x, y));
                       ^
/usr/local/include/zxing/LuminanceSource.h:31:13: note: declared private here
  const int width;
            ^
5 errors generated.

If I change the line 30 to be a public variable, it builds as expected.

natedavis commented 7 years ago

I don't know if it's a specific compile error with zxing, but I do know that if it is a public property, I can compile this program.

Benjamin-Dobell commented 7 years ago

LuminanceSource already has accessors getWidth() and getHeight() please submit a pull request to the project with the offending code.