Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: fili on July 10, 2006, 01:46:44 pm

Title: Paths in headers
Post by: fili on July 10, 2006, 01:46:44 pm
Hmm, I'm a little embarassed because I don't know if my problem is C::B related or gcc related.

I want to create a project with subdirectories. Something like: the main.cpp in the root, then CTest.h and CTest.cpp in a subdirectory called src. If I want to include the header in main.cpp it's easy, just
Code
#include "src/CTest.h"
But if I want to include the same header in CTest.cpp I should write
Code
#include "CTest.h"
because both CTest.h and CTest.cpp are in the same folder. This doesn't work. If I do the same as for main.cpp, it works.
Now my question: is there some setting I should... err... set  :D in C::B (May 24th build) in order for this to work as expected? Or is it a gcc problem? In VC6.0 it works, in gcc it doesn't.

Thanks, Fili
Title: Re: Paths in headers
Post by: killerbot on July 10, 2006, 02:30:02 pm
yes, it's easy ;-)

In your sources just do :
#include "Test.h"

and on your project (or target) you can set a list of directories the compiler should use for looking for included headers.

Check you project build options : directories ...
Title: Re: Paths in headers
Post by: mandrav on July 10, 2006, 02:31:07 pm
...or if you want a behaviour similar to MSVC's do this:

"Settings->Compiler & debugger->Global compiler settings->Other" and check "Explicitely add currently compiling file's directory to search dirs".
Title: Re: Paths in headers
Post by: fili on July 10, 2006, 02:33:54 pm
Thank you, it works. 8)