Fix Windows build with --enable-werror#20586
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
|
I'm a bit divided on whether building on every platform/compiler combination 'with -Werror' is actually a goal of the project. I mean, I think this is impossible, and will result in a lot of warning fixing for the sake of warning fixing. In general Werror is a curse. |
|
Tend to agree with @laanwj, especially if the workarounds will make already hard to understand files like fs.cpp even more verbose. |
vasild
left a comment
There was a problem hiding this comment.
ACK 06ff475
Sometimes important warnings are emitted only on some platforms, so I think it is good to use -Werror on as most platforms as possible.
If keeping Windows builds warning-free turns out to be too big burden then the NO_WERROR=1 can be added back.
Fair enough. The goal of this PR (combined with #20544) is to prevent changes that introduce new warnings. Anyway, feel free to close this. |
|
🕵️ @practicalswift has been requested to review this pull request as specified in the REVIEWERS file. |
|
Concept ACK |
|
Updated 06ff475 -> 926f6d8 (pr20586.01 -> pr20586.02, diff).
Only one-line change in |
src/fs.cpp
Outdated
| static std::string openmodeToStr(std::ios_base::openmode mode) | ||
| { | ||
| switch (mode & ~std::ios_base::ate) { | ||
| switch (static_cast<int>(mode & ~std::ios_base::ate)) { // casting is required to suppress -Wswitch warnings |
There was a problem hiding this comment.
NACK, the standard doesn't guarantee this fits in an int...
Can you use a pragma to disable the warning here?
|
Reverted back 06ff475 <- 926f6d8 (pr20586.01 <- pr20586.02) as was requested by @luke-jr. |
|
Updated 06ff475 -> b367745 (pr20586.01 -> pr20586.03):
|
jarolrod
left a comment
There was a problem hiding this comment.
ACK b367745
Tested on Linux cross-compiling to Windows passing --enable-werror to configure
Master:
script/standard.cpp:215:26: error: control reaches end of non-void function [-Werror=return-type]
215 | std::vector<valtype> vSolutions;
PR:
Builds fine and built binaries work fine on Windows 10
|
cr ACK b367745: patch looks correct |
|
Do you mind having another look at this PR? |
|
|
||
| #if defined(__GNUC__) && !defined(__clang__) | ||
| #pragma GCC diagnostic push | ||
| #pragma GCC diagnostic ignored "-Wswitch" |
There was a problem hiding this comment.
Will this be needed after the boost::fs removal?
There was a problem hiding this comment.
I think no, as this bunch of code should go:
Lines 66 to 69 in d6e0d78
|
I'm not a big fan in general of pragmas or fixing warnings for the sake of fixing warnings but this seems minimal enough. |
This PR makes possible to cross-compile Windows build with
--enable-werror --enable-suppress-external-warnings.Some problems are fixed, others are silenced.
Also
--enable-werroris enabled for Cirrus CI Windows build (the last one on Cirrus CI without--enable-werror).