-
Notifications
You must be signed in to change notification settings - Fork 22
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
Build with -Wpedantic
and -Werror
#305
Comments
Hi @brettviren , thanks for making this issue describing and tracking this problem. Here I attach an example log file for demonstration purpose: These are fixed with this commit: f63acbf using the above I fully agree that in the long run, we want to have gatekeepers to avoid too many sprinkled |
Related #122 |
For the "gatekeepers", could @brettviren suggest what is a proper granularity? |
I see it as a balance between two extremes.
The first extreme is one gatekeeper per offending header and the other is one gigantic include-everything gatekeeper. The extremes should be avoided but otherwise I feel broad optimum. A good rule of thumb is a gatekeeper should not include headers from more than one external package. In the case of Boost, I've tried to narrow to one Boost "topic", eg In the past I have looked at where headers from one external package are included to try to find patterns of use. Eg:
For that example, most already include Where no existing header conveniently serves as a gatekeeper, we can of course create a new one that has only that role. |
This is causing too much headache due to different developers catching/causing different warnings. After developers stop using ancient compilers, perhaps we can reinstate it. Until then: SEE A WARNING FIX A WARNING. Reference: #305. This commit also includes the last batch of fixes prior to removal of the flag. Some of the fixed code is ancient and it is a mystery to me why it never tickled -Werror before.
Basic problem
We want to build WCT with strict compiler checks and so
-Wpendantic
and-Werror
are turned on by default.While we can WCT code itself "clean" this leads to problems when code that is
#include
is itself not "clean" and that will break building with-Wpedantic
and-Werror
.Problem likely to reoccur over time
This issue start to fix a specific instance of this class of problem. However, the problem can reappear as novel versions of existing externals are used to build WCT by the user. Feel free to re-open this issue when those are encountered.
Basic fix
To have our strict compilation while relaxing it for offending external code we must use a non-standard but effectively universal CPP macro
#pragma
.To apply the fix in general, follow this recipe:
#include
pagth.grep
or your favorite tool.#pragma
(see below)#include
of the offending headers in other source and#include
the "gatekeeper header".A "gatekeeper header" is a header file that includes some offending header(s) of some limited set and wraps them in suitable
#pragma
to turn off the strict compiling. This "gatekeeper header" is then used for#include
instead of including the "bare" offending headers.The initial problem
In this inaugural case the two offending headers show up when Boost 1.75.0 and Eigen 3.4.0 are used with GCC 9.3.0.
These are not directly included but are included by other's in Boost and Eigen, respectively.
WCT currently includes
boost/iostreams
related in many places and for different usages. So, it a new "gatekeeper header" for just these is warranted. Let's call thatWireCellUtil/Iostreams.h
in analogy to the existingMultiArray.h
. OTOH, the use of Eigen can likely always go through theArray.h
header and so we can instrument that as the "gatekeeper".Because the build turns on
-Werror
, anything that would merely be a warning becomes an error. This requires two#pragma
for each actual warning. Here is the guts ofMultiArray.h
showing things:The last chore is to replace
#include
of bare offending headers with inclusion of the gatekeeper. Again,grep
or your favorite search mechanism will help find the spots needing editing.The text was updated successfully, but these errors were encountered: