Reputation: 2073
I have a C++ project that I am building on Linux using g++. I have two "include directories" that I have to add as arguments using -I. The problem is that in each of these directories, I have some overlapping and common files. Thus when I have
g++ -o program program.cpp -I/foo/include -I/bar/include
I get compiler warnings like so:
stdint.h:174:0: warning: "__UINT64_C" redefined [enabled by default]
#define __UINT64_C(c) c ## ULL
What is the best way I can include files selectively so that I do not face issues like this?
Upvotes: 1
Views: 1086
Reputation: 182743
Your problems seems to be more due to overlapping definitions than files that happen to have the same name. But either way, I'd suggest the following fix:
Don't use files from both of these libraries in the same file in your application. Have some files that use the first library and some that use the second. Files that use the first library are compiled with its include path. Files that use the second library are compiled with its include path.
If you really need to integrate calls to both libraries in the same code, just wrap one or both libraries with a sanitized interface whose file and identifier names don't conflict with your project's names.
Upvotes: 2