Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22298

Does a compiler flag exists to warn if multiple files with the same name for an include directive exits?

$
0
0

Recently I run into the following problem:
A source file included a header with a non unique file name.
The build suceeds if the Include paths are given in the correct order.

I would like to be warned at compile time if multiple files with the same names exists in the include paths. Please refer to my minimal example for details.Does a compiler flag for this purpose exits ?

Minimal example:

file tree

.├── a│└── h.hxx├── b│└── h.hxx└── main.cxx

a/h.hxx

#ifndef __H_HXX__#define __H_HXX__namespace important {    struct Foo {        int bar;    };}#endif

b/h.hxx

#ifndef __H_HXX__#define __H_HXX__namespace uselesss {}#endif

main.cxx

#include "h.hxx"namespace important {    void bar(){        Foo x;    }}int main(){    important::bar();    return 0;}

compiler invocation

g++ -I a -I b main.cxx<- will work, but i would like to be warned
g++ -I b -I a main.cxx<- will fail, fine >> problem can be fixxed immediatly

Thank you


Viewing all articles
Browse latest Browse all 22298

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>