Arduino environment variables

Hello,

My question is very simple: Is there any environment variable I can use to include a configuration file, coming from the sketch folder, in a library. I have developped a library for communication but want to customize it for each appli, using some #define I would like to include in my library such line:

include "APP/Conf.h"

with APP pointing on the folder where the .ino file is

Thanks

unfortunately I fear it is not possible to include variables inside an #include statement in c/c++ language You should/could use a preprocessor to do that, but unfortunately there are no preprocessor available in arduino env, as far as I know.

have you tried placing conf in the same directory and use

include ".\conf.h" ?

Hi,

Thanks for your answers.

Robtillart: if the configuration file is in the library folder, it's OK. I can compile and run the application but if the configuration file is in the sketch folder, following message is displayed: "D:\arduino-1.0\libraries\MasterSlaveLib\MasterSlaveLib.cpp:34:29: error: MasterSlaveLib_Conf.h: No such file or directory"

My goal is to minimize the code generated regarding sketch configuration (e.g. application shall support all or some Master or Slave or both Master and Slave functions) that's why I need to have some #define.

To solve my problem, II know I can duplicate the library source files in all sketch folders and it will be OK but I loose the advantage to have only one source for all my projects. I can also split my library to several part but maintenance will become very difficult.

OK, I'll continue to investigate

use #ifdef's in yourlib

#ifdef MYLIB_SLAVE 
// slave code
#endif
#ifdef MYLIB_MASTER
//master code
#endif
// common code

then in your sketch state

define MYLIB_SLAVE 1

include "mylib"

etc

to just include the SLAVE part and the common part.

Hi Robtillaart,

Thanks for the time spent.

I've unsuccessfuly tried this a lot and every time got an "undefined reference to" the function between #ifdef and #endif. The only way for the #define to be taken into account by the lib seems to have it in the lib.cpp file itself or in a .h file included in the library.

I've done it a lot of time with other dev environments and was puzzled to fail with Arduino

regards

just gave it a try and indeed it does not work (yet)

checked - http://www.cplusplus.com/doc/tutorial%20%20/preprocessor/ - to see if my advice made sense [seemsOK]

Assume that the Arduino environment does something not in the right order,