stachenov / quazip

Qt/C++ wrapper over minizip
Other
582 stars 232 forks source link

Build break on Linux/macOS #116

Closed trevorsandy closed 8 months ago

trevorsandy commented 3 years ago

Problem

I am experiencing a build break after recently updating to the latest source from v0.78. QuaZip is configured to build as a static library using my existing qmake framework. Essentially, I simply added the new headers and source files since v0.78 to my project config.

The following excerpt from quazip_qt_compat.h highlights both the cause and workaround.

// and another stupid move
 #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
 const auto quazip_endl = Qt::endl;
 /*
  Not used and causing build break:
 ./quazip/quazip_qt_compat.h:142:26: error: unable to deduce 'const auto' from 'std::endl'
  const auto quazip_endl = endl;
 ../quazip/quazip_qt_compat.h:142:26: note:   couldn't deduce template parameter 'auto'
 #else
 const auto quazip_endl = endl;
 */
 #endif

Cheers,

stachenov commented 3 years ago

Hm... It isn't the first time I encounter this.

The true reason has nothing to do with QuaZip. It's because someone has using namespace std or using std::endl before including QuaZip headers. That's a very bad idea in general because you're polluting the global namespace, and that's exactly why it thinks it's std::endl, when it should have been Qt's global endl.

But! Since it occurs so often, and it's indeed not used anywhere except in tests, I'm starting to think of splitting this header into quazip_qt_compat.h and qztest_qt_compat.h. This will “fix” the issue, even if not its cause.

trevorsandy commented 3 years ago

Indeed, I did suspect the cause not to stem from QuaZip.

You are on point. I found a rogue using namespace std; in one of my headers - it should have been moved to source.

Cheers,