Page 1 of 1

djgpp and includes [Solved]

Posted: Thu Apr 19, 2007 1:54 am
by crackers
Hi all
I've a little problem. I've divided my source files into directories, something like this:

Code: Select all

c:\
  OS
      main.c
      DirectoryA
           DirectoryA1
                 File1.h
                 File1.c
      DirectoryB
           DirectoryB1
                 File2.h
                 File2.c
           DirectoryB2
                 File3.h
                 File3.c
in main.c I've

Code: Select all

#include "DirectoryA\DirectoryA1\File1.h"

int main(void)
{
  return 0;
}
in File1.h I've

Code: Select all

#include "DirectoryB\DirectoryB1\File2.h"
And I'm getting error durring compilation of main.c that in File1.h there is include to not existing file "DirectoryB\DirectoryB1\File2.h". I can change it to

Code: Select all

#include "..\..\DirectoryB\DirectoryB1\File2.h"
// or
#include "c:\OS\DirectoryB\DirectoryB1\File2.h"
but it does'nt look nice to me. I've tried to add to file djgpp.env entries under [gcc] like
INLCUDE_PATH=c:/OS
GCC_INLCUDE_PATH=c:/OS
but it's not working. Any ideas?

Posted: Thu Apr 19, 2007 1:24 pm
by Alboin
What about something like:

Code: Select all

gcc -I/directory/ main.c
and then

Code: Select all

#include <File2.h>

Posted: Fri Apr 20, 2007 9:26 pm
by earlz
in File1.h I've
Code:

#include "DirectoryB\DirectoryB1\File2.h"
If you don't do what Alboin said, then you should add .. to the first of it, like
# include "..\..\DirectoryB\DirectoryB1\File2.h"

btw if you plan to make things portable use / rather than \

Posted: Mon Apr 23, 2007 2:46 am
by crackers
Thx it worked . :D