This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

#include file in a subdirectory

Hi,

I'm using the C166 compiler. I'm trying to restructure a project, and wanted to put serveral related files in a subdirectory, say "thing". We have several source and header files that look like

./thing1_this.c
./thing1_this.h
./thing1_that.c
./thing1_that.h
./thing2_this.c
./thing2_this.h

I want to create subdirectories

thing1/

and and

thing2/

and to move these to

thing1/
  thing1/this.c
  thing1/this.h
  thing1/that.h
  thing1/that.h
thing2/
  thing2/this.c
  thing2/that.h

Then the files which include the header files would go from

#include "thing1_this.h"
#include "thing1_that.h"
#include "thing2_this.h"

to this:

#include "thing1/this.h"
#include "thing1/that.h"
#include "thing2/this.h"

The compiler can't find the header files in this configuration. I've tried other path separators ('\\', '\'), but to no avail. I have './' explicitely in my

INCDIR(...)

directive.

I've also made sure that the directory name is within DOS filename limits.

The description of the include search method in the manual was very sparse, and I could find nothing on the forums how this might be done or whether the compiler could do this at all.

Is this a limitation of the compiler that the preprocessor doesn't know how to include file paths? Or is their some syntax I haven't tried?

If I must I can put

./thing1

and

./thing2

in my

INCDIR(...)

directive and name this files like this:

thing1/
  thing1/thing1_this.c
  thing1/thing1_this.h
  thing1/thing1_that.h
  thing1/thing1_that.h
thing2/
  thing2/thing2_this.c
  thing2/thing2_that.h

but my original setup is better, and I'd like to do that if I can.

Thanks Much.

Parents
  • I'm not sure what they mean with "current folder".
    

    I had assumed that they meant "Current working directory of the compiler process". But it seems not.

    In case you shorten the name of your header files
    so you get "thing1/this.h" and "thing2/this.h"
    then you have two files with the same name.
    

    Yes. It's not an issue, though, if they are always included as "thing1/this.h", etc.

    Another issue to think about is having multiple
    source directories with "this.c" - since that will
    produce multiple "this.o" or "this.obj". If the
    compiler tries to store all object files in a
    common output directory then bad things will happen.
    

    That's true. Of course, these were just example file names for the sake of posing the question. Ideally, the output directory hierarchy would mirror your source file directory structure, so that "src/thing1/this.c" would compile to "output/thing1/this.obj", and so on.

    Thanks

Reply
  • I'm not sure what they mean with "current folder".
    

    I had assumed that they meant "Current working directory of the compiler process". But it seems not.

    In case you shorten the name of your header files
    so you get "thing1/this.h" and "thing2/this.h"
    then you have two files with the same name.
    

    Yes. It's not an issue, though, if they are always included as "thing1/this.h", etc.

    Another issue to think about is having multiple
    source directories with "this.c" - since that will
    produce multiple "this.o" or "this.obj". If the
    compiler tries to store all object files in a
    common output directory then bad things will happen.
    

    That's true. Of course, these were just example file names for the sake of posing the question. Ideally, the output directory hierarchy would mirror your source file directory structure, so that "src/thing1/this.c" would compile to "output/thing1/this.obj", and so on.

    Thanks

Children
  • "Ideally, the output directory hierarchy would mirror your source file directory structure, so that "src/thing1/this.c" would compile to "output/thing1/this.obj", and so on."

    Exactly. But I don't use the C166 tools so I don't know - it's just something to be careful with as it may create problems.