mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-03-02 22:57:32 -05:00
clang (c++11) compiler fails to compile static const QStringList deleteFilesList = #3685
Labels
No labels
Accessibility
AppImage
Bounty
Build system
CI
Can't reproduce
Code cleanup
Confirmed bug
Confirmed bug
Core
Crash
Data loss
Discussion
Docker
Documentation
Duplicate
Feature
Feature request
Feature request
Feature request
Filters
Flatpak
GUI
Has workaround
I2P
Invalid
Libtorrent
Look and feel
Meta
NSIS
Network
Not an issue
OS: *BSD
OS: Linux
OS: Windows
OS: macOS
PPA
Performance
Project management
Proxy/VPN
Qt bugs
Qt6 compat
RSS
Search engine
Security
Temp folder
Themes
Translations
Triggers
Waiting diagnosis
Waiting info
Waiting upstream
Waiting web implementation
Watched folders
WebAPI
WebUI
autoCloseOldIssue
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/qBittorrent#3685
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @yurivict on GitHub (Jan 6, 2016).
These lines:
cause an error with clang-3.4.1:
Happens with both qt4 and qt5.
This might be implicitly using some gcc extension. Not sure.
You might want to remove the (possibly non-standard) constructor, and only delete based on the platform (with ifdefs). Or just list them all explicitly.
@Chocobo1 commented on GitHub (Jan 7, 2016):
Does removing
statickeyword fix the error? (probably not. BTW, I see no reason of using it)@yurivict commented on GitHub (Jan 7, 2016):
No, static has nothing to do with this.
@Chocobo1 commented on GitHub (Jan 7, 2016):
What about your Qt version?
@yurivict commented on GitHub (Jan 7, 2016):
I tried both 4.8.7 and 5.4.1
@glassez commented on GitHub (Jan 7, 2016):
clang supports initializer lists starting from version 3.1 (See http://clang.llvm.org/cxx_status).
Maybe you forgot to use -std=c++11 when you built Qt? Or maybe Qt incorrectly determines the capabilities of your compiler?.. Unfortunately, it happens. Try to explicitly define Q_COMPILER_INITIALIZER_LISTS.
@yurivict commented on GitHub (Jan 7, 2016):
My compiler is clang 3.4.1
Command line does include -std=c++11.
And it doesn't matter how Qt itself was compiled, as this is the compile-time error we are talking about. Qt doesn't determine any compiler capabilities here.
@naikel commented on GitHub (Jan 7, 2016):
It is a Qt problem. Qt has to be rebuilt with CONFIG += c++11 in qt.pro.
Please don't do things like QMAKE_CXXFLAGS += -std=c++11. That would be insufficient.
It's a common problem and very well documented all over the Internet.
@naikel commented on GitHub (Jan 7, 2016):
Also:
If you read the error a little it says that Qt didn't include that constructor for C++11. That's why it fails. If you recompile Qt properly the constructor will be included, and the program will compile successfully.
Remember this is Object Oriented Programming. Anything that has an object and an equal sign just after it needs a constructor. This is not plain C.
@yurivict commented on GitHub (Jan 7, 2016):
Could you please pinpoint how does the qt build factor into the header-only compilation of
qBittorrent? You realize that the failure occurs during the compile-only phase?
@naikel commented on GitHub (Jan 7, 2016):
In Qt 4.x you would have to recompile it.
Qt 5.x should support C++11 fully. Try the suggestion above, defining Q_COMPILER_INITIALIZER_LISTS, maybe Qt isn't detecting properly that your compiler needs it.
@yurivict commented on GitHub (Jan 7, 2016):
Only headers are used during qbittorent compilation. I don't see how headers depend on the way how qt was compiled.
@glassez commented on GitHub (Jan 8, 2016):
@yurivict, try add following lines before:
and recompile. What do your compiler say in this case?
@glassez commented on GitHub (Jan 8, 2016):
And yet...
@yurivict, what Qt build you use? I assume you're doing a custom build, since there are no official Qt builds for clang.
@yurivict commented on GitHub (Jan 8, 2016):
The problem only occurs with Qt4. Qt5 doesn't have this problem.
@glassez the #error Q_COMPILER_INITIALIZER_LISTS is undefined! does get triggered.
It appears that qBittorrent isn't compatible with Qt4 in this place.
I use an official FreeBSD build of Qt port.
But I can easily patch this, I only reported here because I felt this place is better removed. It doesn't look like the right code anyway.
@Chocobo1 commented on GitHub (Jan 8, 2016):
But it is valid C++11 code.
https://en.wikipedia.org/wiki/C%2B%2B11#Initializer_lists
http://blog.qt.io/blog/2011/05/26/cpp0x-in-qt/
http://doc.qt.io/qt-4.8/qstringlist.html#QStringList-5
@yurivict commented on GitHub (Jan 8, 2016):
The same compiler understands it for Qt5 but not for Qt4. It might be that DEFINES += Q_COMPILER_INITIALIZER_LISTS is required for Qt4, and is pre-defined for Qt5. I don't know where Q_COMPILER_INITIALIZER_LISTS is normally defined, but in both Qt4 and Qt5 such constructor is only available with Q_COMPILER_INITIALIZER_LISTS.
@naikel commented on GitHub (Jan 8, 2016):
It is defined in qcompilerdetection.h but don't think Qt4 has Q_COMPILER_INITIALIZER_LISTS. You can check looking at the header of, for example, qstringlist.h (this issue was opened because of that). You should see something like this in Qt5:
But I don't think you would see that in a qstringlist.h of Qt4.
Back to qcompilerdetection.h, to define Q_COMPILER_INITIALIZER_LISTS for clang, __cplusplus has to be >= 201103L and __has_feature(cxx_generalized_initializers) has to be true.
@yurivict commented on GitHub (Jan 8, 2016):
I personally don't care, but it seems it is easiest to remove this code to make qbitorrent more compatible.
@glassez commented on GitHub (Jan 8, 2016):
qBittorrent uses c++11 now. All compilers and Qt versions supported by qBittorrent support c++11. We are not going to abandon this, if someone can't configure it.
@yurivict commented on GitHub (Jan 8, 2016):
Who can't configure it?
@sledgehammer999 commented on GitHub (Jan 8, 2016):
@yurivict look at my comment here. The same file controls things for the other compilers too. Try to figure out why it doesn't enable that define for clang.
@yurivict commented on GitHub (Jan 8, 2016):
In Qt4 Q_COMPILER_INITIALIZER_LISTS is defined only when _LIBCPP_VER is defined, and _LIBCPP_VER isn't defined for me. So the constructor that you use isn't (always) defined by default in Qt4. Qt5 has different logic for Q_COMPILER_INITIALIZER_LISTS. I don't know if I should set _LIBCPP_VER. Why should I? What is it? Why isn't it set?
@yurivict commented on GitHub (Jan 8, 2016):
"Go to line 920 and uncomment it" doesn't work because this is the standard installation. Can't touch it. In short, qBittorrent isn't generally compatible with Qt4 out of the box due to this one line.
@sledgehammer999 commented on GitHub (Jan 8, 2016):
IIRC "clang" is among the unsupported or partially supported compilers by qt. Also qt4 isn't updated anymore and that's why it doesn't work. I think it is the job of the FreeBSD maintainer of qt4 to patch things up so they work(ie find what needs to be done to enable the
Q_COMPILER_INITIALIZER_LISTS)Sure but you could look at that file and see why it isn't enabled.
@yurivict commented on GitHub (Jan 8, 2016):
Okay then, this is clang fault, it is unsupported, and nobody else uses it. So I close this then. I am not suffering from this. There are much more important issues.
@sledgehammer999 commented on GitHub (Jan 8, 2016):
Well it isn't clang's fault. It supports that feature. It is qt4's fault which is old and isn't configured correctly for clang. While qt5 is configured correctly which proves that clang works.
@glassez commented on GitHub (Jan 8, 2016):
Qt4 supports c++11 features if used compiler supports it. There is simply no reliable way to determine the characteristics of future versions of the compilers. Or, maybe Qt4 just does it incorrectly. So there is nothing wrong to fix legacy configuration files.
@yurivict commented on GitHub (Jan 8, 2016):
Thanks to everybody for helping to clarify this issue.
It became 100% clear what is happening in this case.