Need some help on include & paths [solved]

Posted By: peteredlin

Need some help on include & paths [solved] - 08/07/12 08:20

Hello,

My project consists of multiple scripts in multiple sub-folders.
But i need some help on how to set the include path right.

example:
main script includes a script in subfolder called "config.c".
Then config.c needs to include a script which is in another subfolder of the main work-folder.

How do i do this?

Posted By: MasterQ32

Re: Need some help on include & paths - 08/07/12 08:26

you need to setup the paths correctly
the preprocessor moves its current working path to the directory where the current file is
so all files referenced in main.c are relative paths to the folder where main.c is
all referenced files in config.c are relative to the folder of config.c

Code:
|- project folder
 |- main.c
 |- config files
  |- config.c
 |- player
  |- player.c
  |- enemy.c
  |- movement.c


(I hope this file system tree is clear enough)

to include all those files you write this:
Code:
// main.c:
#include "config files\config.c"
[...]

// config.c:
#include "..\player\player.c"
#include "..\player\enemy.c"
#include "..\player\movement.c"



with .. you can navigate to the containing folder, so "dev\pla\..\.." is the current directory wink
Posted By: peteredlin

Re: Need some help on include & paths - 08/07/12 08:45

Thanks for the speed-help!:)
Posted By: MasterQ32

Re: Need some help on include & paths - 08/07/12 09:24

no problem grin
© 2024 lite-C Forums