This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

g++ include handling question


I have a question on how g++ is expected to handle includes.

Given this demo.cpp and two include files of the same name demo.h.
One demo.h is in the ./ dir the other in the .. dir.

./demo.h
	#define defined_var "this is from ./demo.h"

../demo.h
	#define defined_var "this is from ../demo.h"

./demo.cpp
	#include <iostream>
	#include <demo.h>
	using namespace std;

	int main()
	{
		cout << defined_var << endl;
	}

g++ demo.cpp -I. -I.. -o demo

Running demo "this is from ../demo.h" is written to stdout.

Changing #include <demo.h> to #include "demo.h" the ./demo.h is used.

Is this a bug or should one always have to quote local (./) include files?

In kde-3.0.x several such cases occur and lead to compile errors.


Please cc the anser to me, I am not on this list.

-- 
Klaus


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]