-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMake: fix MSVC __cplusplus #13934
CMake: fix MSVC __cplusplus #13934
Conversation
First, IIRC qbt code doesn't use this macro, so we don't actually need it nor do anything about it. |
Even if qbt doesn't use this macro directly it still might be used indirectly, e.g. if libtorrent uses it in headers. But in this case, we should not touch it manually, and use exactly the same value as libtorrent, otherwise we may get conflicts. |
I would expect libtorrent to propagate it in cxx flags in the case of cmake. |
It's still useful for our own code. Right now, we don't seem to have any problem due to the macro taking on the wrong value, but I think that's because we are just lucky. Consider that MSVC uses C++14 by default: https://docs.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=msvc-160 - if we are to switch to C++17 soon in our code base, there will again be a mismatch between the macro and the As far as compatibility with libtorrent goes: there is no problem because of exactly this:
But if something is important for our own code, we should not rely on a dependency to propagate it to exempt us from declaring it ourselves. Propagation of requirements is to be relied upon for requirements that are specific to the dependency only, not general ones that happen to coincide. |
@FranciscoPombal, why are you always so needlessly verbose? I just meant that we can safely enable this flag only if it is enabled when compiling all the linked libraries. |
And I'm saying that we can and should safely enable it because there is no dependency that we consume, nor any piece of our own code, that assumes the macro is hardcoded to the wrong value. The dependencies we use actually employ it for feature detection (which is its intended purpose anyway)[1], so we ought to make sure it is set to the correct value as well. Only very old legacy code assumes this macro is hardcoded to the wrong value and will break when this option is passed. Maybe you should investigate a little yourself instead of complaining about other people taking their time to explain things clearly to you. [1]: an example in libtorrent: https://github.com/arvidn/libtorrent/blob/b029d4f296df5ca53c5fce24cd781c235e2484ac/include/libtorrent/units.hpp#L160. This is why arvidn/libtorrent#5336 makes sure the correct code will be used when building with CMake and MSVC. |
Maybe you should discuss exactly the aspects of the problem that you are asked about, instead of thinking everyone around you is a moron who needs to be explained everything from scratch.
Doesn't your example confirm my concerns? |
This is frankly a stupid assumption. I don't explain things because I think you're a moron. There is nothing to lose by explaining things clearly. If you understand what is said, and even think the explanation is too verbose for you, good for you, no need to feel insulted (why would you?). In fact, a clear explanation benefits lurkers and other participants who may come come across this and not be as knowledgeable as you. This increases the chance that a third party might contribute something useful for the discussion that they otherwise wouldn't have been able to because of trouble understanding a new subject. These kinds of reactions against clear explanations make those less knowledgeable feel inadequate - they will avoid participating because they will fear being judged too harshly by you through no fault of their own. This creates a negative environment for information sharing.
I tested briefly on Windows, and IIRC the result was a few compilation warnings (or maybe I tested the other combination, libtorrent without arvidn/libtorrent#5336 and qBittorrent with this patch). Basically the warnings that were appearing on libtorrent were "moved up" to qBittorrent compilation time. So I'd say it's not much of a regression, but not much of an overall improvement either. I still think the likelihood of any kind of problem arising from such a combo is extremely low, but yeah, why risk it? I agree we have more to gain by waiting for the 1.2.12 release before merging this. |
267abff
to
bd34454
Compare
As per the discussions in arvidn/libtorrent#5114, this change was also implemented in libtorrent: arvidn/libtorrent#5336 (long ago now, I think the first tagged release that included this was 1.2.12). Now it's our turn, as none of the hypothetical concerns that were raised came to fruition. |
See this comment onward in the libtorrent issue tracker: arvidn/libtorrent#5114 (comment).
Basically, this prevents deprecation warnings due to erroneous values of the
__cplusplus
macro on MSVC. See https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ for more info. The only reason this is not default is because otherwise it would break legacy code relying on MSVC to always setting this to the same value.I realize the commit title might not be the best, open to suggestions.