g++c-preprocessorhdf5gcc7

Have GCC preprocessor treat angle brackets as quotes


I'm trying to make use of system headers that make use of angle-brackets where quotes should have been used. Specifically I have a system-supplied header file in /usr/include/hdf5/serial/ which contains

#include <hdf5.h>

I could of course pass G++ the option -isystem /usr/include/hdf5/serial, but I'd rather keep things modular, and not replicate this piece of configuration to any project that could ultimately consume this header.

I'm using G++ 7.3 on Ubuntu 18.04 and CentOS 7.x with DevToolset 7.


Solution

  • What you propose is the only sensible solution - the library requires you to add that directory to the compiler's system-includes path. To isolate that from programs using your headers, you could forward-declare just the things you need from the library, or you might need some sort of abstraction layer. Or just forward the library's pkg-config in your own library's .pc file.