Skip to content
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

include Ogre headers via system path #1630

Conversation

v4hn
Copy link
Contributor

@v4hn v4hn commented Jun 7, 2021

... to silence warnings about upstream files.

According to the pkgconfig and the cmake files of Ogre, /usr/include
is an include folder for the project and thus <OGRE/Ogre...> is a valid include path.

The following illustrates the behavior with one of various warnings:
<<<
❯ cat bar.cpp
❯ clang++ -Werror -Wall -Wextra -pedantic -std=c++14 -c bar.cpp -I/usr/include/OGRE
In file included from bar.cpp:1:
In file included from /usr/include/OGRE/OgrePixelFormat.h:31:
In file included from /usr/include/OGRE/OgrePrerequisites.h:326:
In file included from /usr/include/OGRE/OgreMemoryAllocatorConfig.h:188:
/usr/include/OGRE/OgreMemorySTLAllocator.h:130:4: error: 'register' storage class specifier is deprecated and incompatible with C++17 [-Werror,-Wdeprecated-register]
register size_type sz = count*sizeof( T );
^~~~~~~~~
1 error generated.
❯ cat foo.cpp
❯ clang++ -Werror -Wall -Wextra -pedantic -std=c++14 -c foo.cpp

<<<

RViz surpresses these warnings with include_directories(SYSTEM ${OGRE_INCLUDE_DIRS})
but passes the plain OGRE_INCLUDE_DIRS variable on in catkin_package(INCLUDE_DIRS ...).
There is no way to specify a SYSTEM include there.
Consequently all downstream projects including rviz headers will see OGRE's warnings
and have no easy way to avoid them because the correct OGRE include path is only one entry in
${rviz_INCLUDE_DIRS} (or more likely ${catkin_INCLUDE_DIRS}).

Came up in moveit/moveit_task_constructor#273 (comment)

... to silence warnings about upstream files.

According to the pkgconfig and the cmake files of Ogre, /usr/include
is an include folder for the project and thus <OGRE/Ogre...> is a valid include path.

The following illustrates the behavior with one of various warnings:
<<<
❯ cat bar.cpp
❯ clang++ -Werror -Wall -Wextra -pedantic -std=c++14 -c bar.cpp -I/usr/include/OGRE
In file included from bar.cpp:1:
In file included from /usr/include/OGRE/OgrePixelFormat.h:31:
In file included from /usr/include/OGRE/OgrePrerequisites.h:326:
In file included from /usr/include/OGRE/OgreMemoryAllocatorConfig.h:188:
/usr/include/OGRE/OgreMemorySTLAllocator.h:130:4: error: 'register' storage class specifier is deprecated and incompatible with C++17 [-Werror,-Wdeprecated-register]
                        register size_type sz = count*sizeof( T );
                        ^~~~~~~~~
1 error generated.
❯ cat foo.cpp
❯ clang++ -Werror -Wall -Wextra -pedantic -std=c++14 -c foo.cpp
❯
<<<

RViz surpresses these warnings with `include_directories(SYSTEM ${OGRE_INCLUDE_DIRS})`
but passes the plain OGRE_INCLUDE_DIRS variable on in catkin_package(INCLUDE_DIRS ...).
There is no way to specify a SYSTEM include there.
Consequently all downstream projects including rviz headers will see OGRE's warnings
and have no easy way to avoid them because the correct OGRE include path is only one entry in
${rviz_INCLUDE_DIRS} (or more likely ${catkin_INCLUDE_DIRS}).
@rhaschke
Copy link
Contributor

rhaschke commented Jun 7, 2021

I hesitate to adapt all the include directives. I'd prefer the solution suggested in moveit/moveit_task_constructor#273 (comment).

@v4hn
Copy link
Contributor Author

v4hn commented Jun 7, 2021

Actually this is the way gazebo includes ogre for at least 10 years, so I believe this would be a viable option for RViz as well.

As I stated elsewhere, the alternative to fixing it using the include path would be to overlay the used Ogre headers in a folder in RViz and use something like this

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-register"
#include_next <OgrePixelFormat.h>
#pragma GCC diagnostic pop

in the respective files.

As you stated yourself, this is a limitation in catkin, but it should be fixed in RViz.

@rhaschke
Copy link
Contributor

rhaschke commented Jun 7, 2021

The OGRE tutorials recommend the old way of including OGRE headers.
However, I'm fine merging this as long as it builds 😉

@rhaschke
Copy link
Contributor

I fixed the build issues and merged these changes as 41d62f5.

@rhaschke rhaschke closed this Jun 11, 2021
@v4hn
Copy link
Contributor Author

v4hn commented Jun 11, 2021

I guess you really don't like such issues to remain open PRs for long.
Sorry I couldn't find the time to clean it up and thank you a lot!

@rhaschke
Copy link
Contributor

I just have some time today to handle open rviz issues and this was an easy one ;-)

@rhaschke
Copy link
Contributor

Hi @v4hn, @simonschmeisser, @jspricke
9 months after merging this change, I ran into a problem because we changed OGRE include paths: Trying to build rviz against OGRE 1.13.x installed in a non-standard location, ${OGRE_INCLUDE_DIRS} points to <install folder>/include/OGRE, not <install folder>/include. Thus, all rviz includes of the (new) form (#include <OGRE/...>) fail and fallback to /usr/include/OGRE instead! I'm tempted to revert this change. Any other suggestions?

@jspricke
Copy link
Contributor

${OGRE_INCLUDE_DIRS} points to /usr/include/OGRE for me (Debian unstable, ogre 1.12.10) as well and also OGRE.pc has Cflags: -I${includedir} -I${includedir}/OGRE -pthread so reverting this seems correct to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants