djgpp and includes [Solved]

Programming, for all ages and all languages.
Post Reply
User avatar
crackers
Member
Member
Posts: 27
Joined: Wed Nov 15, 2006 6:31 am

djgpp and includes [Solved]

Post 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?
Last edited by crackers on Mon Apr 23, 2007 2:46 am, edited 1 time in total.
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post by Alboin »

What about something like:

Code: Select all

gcc -I/directory/ main.c
and then

Code: Select all

#include <File2.h>
C8H10N4O2 | #446691 | Trust the nodes.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post 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 \
User avatar
crackers
Member
Member
Posts: 27
Joined: Wed Nov 15, 2006 6:31 am

Post by crackers »

Thx it worked . :D
Post Reply