Author Topic: Paths in headers  (Read 3420 times)

Offline fili

  • Multiple posting newcomer
  • *
  • Posts: 15
  • Meow
Paths in headers
« 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
Have FUN,
FeeL E!

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Paths in headers
« Reply #1 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 ...

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Paths in headers
« Reply #2 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".
Be patient!
This bug will be fixed soon...

Offline fili

  • Multiple posting newcomer
  • *
  • Posts: 15
  • Meow
Re: Paths in headers
« Reply #3 on: July 10, 2006, 02:33:54 pm »
Thank you, it works. 8)
Have FUN,
FeeL E!