0

Let's say I've got directory a/ with two other directories b/ and c/ in it.

main.c is in b/ but I need to include to it headers.h file which is in c/, is there any way I can go one directory up from b/ to a/ and then include headers.h like this?

#include "c\headers.h"

I want to avoid specyfying the whole path

#include "C:\Program Files\a\c\headers.h"

so that wherever a/ is moved, main.c will still work fine

Igor
  • 163
  • 6

1 Answers1

1

Most C compilers accept the -I preprocessor option, adding some directory to the include search path.

So configure your build (probably your build automation tool, e.g. your Makefile if you use make) to add such a flag to the compilation command.

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547