-
Notifications
You must be signed in to change notification settings - Fork 466
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
Fix compilation warnings #1019
Fix compilation warnings #1019
Conversation
Note that all jenkin builds are marked unstable until the warnings are fixed. I think that policy is fine, but then there should be no warnings on the devel branch (which this PR addresses). |
@@ -204,7 +204,7 @@ include_directories(SYSTEM | |||
${OPENGL_INCLUDE_DIR} | |||
${PYTHON_INCLUDE_PATH} | |||
) | |||
include_directories(src ${catkin_INCLUDE_DIRS}) | |||
include_directories(src SYSTEM ${catkin_INCLUDE_DIRS}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to use SYSTEM
, it's known to cause all sorts of problems with the include order on some OS's.
Please use the diagnostics pragma's to disable the particular warnings when including the problem headers. See:
https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html
Here's an example of it in use:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate on that? I have never had or heard of problems with marking include directories as system directories and it is the cleanest way for the compiler to ignore errors in external headers.
It is the least compiler specific and it does not depend on the exact contents of the external headers, which is not under control of this package (so can change and fix or add new warnings).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, the SYSTEM
directive ends up using -isystem
as the option to the compiler. The -isystem
paths are always looked at after -I
, and if a path is specified with both, the -I
entry is ignored:
From https://gcc.gnu.org/onlinedocs/cpp/System-Headers.html:
All directories named by -isystem are searched after all directories named by -I, no matter what their order was on the command line. If the same directory is named by both -I and -isystem, the -I option is ignored.
So that means that when you use it with header paths that may be coming from a workspace, like ~/my_ws/install/include
, and from somewhere else you have an -I/opt/ros/kinetic/include
, then you can get in a situation where you use the headers from /opt/ros
rather than the headers from ~/my_ws/install
even when the workspace should take precedence. Also catkin_INCLUDE_DIRS
is sorted by workspace prefix to avoid a similar problem, so adding these include unevenly may result in unexpected, and hard to debug, behavior when using a workspace.
Also, on OS X, the isystem
flag is used to control which SDK you're using and it caused problems in the past to have more instances of that, though I think CMake/Apple fixed that at some point.
I think in this case it would be ok to use it since we're putting all headers under SYSTEM
, but because of the subtle issues with isystem
I don't want to introduce it in case someone adds more headers later without understanding the pitfall. If you don't want to take the time to suppress the warns with the #pragma
's, then I'll take care of it. Thanks for the fixes you've provided so far!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I did not take into account multiple workspaces. That issue is unfortunate, as it doesn't seem like something that can easily be worked around.
My main hesitation with using pragmas is that they should be maintained properly to stay in sync when new warnings are added by the external dependency. Also, removing unneeded pragmas becomes difficult since it would mean reintroducing warnings when compiling with older versions of the external dependency. On the other hand -isystem
more clearly communicates the intent ("these headers are not mine, don't blame me") and doesn't require maintenance.
Is there perhaps a pragma for gcc and clang which has the same effect on an included header as -isystem
? That would fix the problem without adding a maintenance burden while avoiding include path order issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, there is this:
#pragma GCC system_header
This pragma takes no arguments. It causes the rest of the code in the current file to be treated as if it came from a system header. See System Headers.
But the rest of the file is too broad. If that could be turned off again it would be perfect...
Depending on the exact behaviour of that pragma it could be possible to wrap offending headers in a header with that pragma, but that is getting a bit insane...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was thinking that too. On the one hand it seems a bit overkill, but on the other hand a separate wrapper header would be the best way anyway if the offending include is used multiple times. And then #pragma GCC system_header
is viable option again.
I'll go for that I suppose =]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is still a larger maintenance burden of course, since external dependencies can still introduce warnings in other headers. I'm now wondering again if including everything external with SYSTEM
isn't actually the best option.
An additional complication is that I don't get any warnings from external dependencies locally, even without the CMakeLists.txt
modifications and a clean configure+build (gcc 6 defaults to c++11, where this specific warning is gone). I can go by the log from Jenkins of course, but it does illustrate the problem with manually disabling warnings from specific includes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, as I said, I'm not interested in maintaining the use of SYSTEM
, but I'll take on the work of maintaining suppression of warnings from other headers. I can't take care of this today, but perhaps this weekend I can add what's needed to your PR here and merge it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. I'll remove the CMakeLists.txt
changes commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
Managed to trigger the warnings locally by adding compiling with
It is also a rather serious warning. Technically |
Yes, they should probably export the flag in that case. As of Kinetic they're allowed to use C++11 if they want. |
If interested, see ros/resource_retriever#7 for that discussion. |
Oh, and of course another option to get rid of the |
Ok, I undid the fake system header commit and turned on c++11 (faf97be) and then merged to master. |
Thanks for the contribution and your patience. |
You too ;) And great to have C++11 in rviz |
…/pr-1018 Don't pass screw_display.hpp to the moc generator. (backport ros-visualization#1018)
This PR fixes compilation warnings (all of them with gcc 6.1.1 20160501).
I was a bit confused by the existence of
setUserData
but the absence ofgetUserData
. It seems like a pointless member functions without a matching getter. I changedsetUserData
to not use the deprecatedOgre::MoveableObject::SetUserAny
, and when I wanted to update the getter I noticed it wasn't there.