1

Consider the following code where test.h attempts to include the file "signal.h" using braced include.

Signal.h:

#define xyz 5
int testvar;

test.h:

#if !defined (_C1)
#define _C1
#include <signal.h>
int testvar2;
#endif

test.cpp:

#include "test.h"

If you compile with:

g++ -dD -E test.cpp -o C1.i

All is fine and the system signal.h is pre-pended to test.cpp. However, if you compile with:

g++ -dD -E -I. test.cpp -o C1.i

The local Signal.h is pre-pended, even if it has a different case.

Is this intended behavior? This is affecting gcc-4.7, gcc-5.4 on an Ubuntu.

Thank you

JFMR
  • 23,265
  • 4
  • 52
  • 76
toomanychushki
  • 149
  • 1
  • 6

1 Answers1

0

You included the current directory as part of the search path (what #include <> looks at), that is what the -I. does. It should be fully expected to get a signal.h from the local directory first in this case. As for file name case that would dpend on your system, if the system is case-sensitive then #include should be as well, if it is not then well...

I must say that -I. is very unusual as #include "" already starts there.

SoronelHaetir
  • 14,104
  • 1
  • 12
  • 23