stachenov / quazip

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

Error with Qt 5.12 when building against quazip 1.1 #113

Closed lgbaldoni closed 3 years ago

lgbaldoni commented 3 years ago

Using Qt 5.12.7 and QuaZip 1.1.

When building a package, I'm seeing this error:

/usr/include/QuaZip-Qt5-1.1/quazip/quazip_qt_compat.h:142:26: error: unable to deduce 'const auto' from 'std::endl'
 const auto quazip_endl = endl;
                          ^~~~
/usr/include/QuaZip-Qt5-1.1/quazip/quazip_qt_compat.h:142:26: note:   couldn't deduce template parameter 'auto'

Someone suggested me that line 142 should become #define quazip_endl '\n' << Qt::flush: what do you think?

stachenov commented 3 years ago

Replacing proper symbols with defines doesn't sound like a particularly good idea. It doesn't sound that bad either, though.

But that particular define looks terribly wrong. Why \n? Is it what Qt defines as endl? I'm not sure. There can be more to it.

I need to look into it further, but I need to know what OS and compiler you're using. I have absolutely no problems on all systems and compilers I test QuaZip with.

lgbaldoni commented 3 years ago

I need to look into it further, but I need to know what OS and compiler you're using. I have absolutely no problems on all systems and compilers I test QuaZip with.

The failure occurs on openSUSE Leap 15.3 beta with the stock gcc 7.5.0. compiler. I think I tried version 10 too but with no change.

stachenov commented 3 years ago

I've finally found some time to look into it. Looks like someone did a using namespace std or using std::endl before including QuaZip headers. Unfortunately, this causes name clash with Qt's endl which is a global function (not \n!). I could find no workaround, even referring explicitly to ::endl or QT_PREPEND_NAMESPACE(endl) doesn't seem to work, as that using declaration brings std::endl into the same top-level namespace.

The correct way to fix it is to simply not do that. Don't pollute the top level namespace until you've included every header you need.

Qt 5.15 moves that into the Qt namespace and therefore fixes the problem, which is reflected in quazip_qt_compat.h.

lgbaldoni commented 3 years ago

Moving an #include line did indeed fix the problem. Thank you very much!