[SOLVED] Referencing define in another file

I've got a project that I would like to publish on google code. The problem is that the code contains a api key which obviously I dont want to publish. I could remove it from the local source code but then everytime I rest the code I would need to put the key back in.

Currently the key is defined at the top of my program as

#define apikey "my key here"

What I would like to do just include the key in a separate file and then not sync that to google code. I've tried adding in a new file called key.ino but I think at compile time the key then gets added to the bottom of the main program so that it fails to compile.

I can't use it in a #include as its only a define.

Any suggestions, or is there a simple solution I'm over looking?

"I can't use it in a #include as its only a define."

In traditional C, that is exactly where #defines are supposed to go!

If you are worried about name space collision you can make them "idimpotent":

ifndefined(API_KEY_FILE)

#define API_KEY_FILE
#define my_api_key
#endif

Better still, make them "idempotent"

KeithRB:
"I can't use it in a #include as its only a define."

In traditional C, that is exactly where #defines are supposed to go!

If you are worried about name space collision you can make them "idimpotent":

ifndefined(API_KEY_FILE)

#define API_KEY_FILE
#define my_api_key
#endif

I'm afraid you've completely lost me. :frowning:

Should I create a file, say "api_key_file" and it in put the apikey. Then use the above code in my main program?

You create a .h file with the commands I used and then #include it.

Edit to Bold, Italicize, and Underline stuff!

What I would like to do just include the key in a separate file and then not sync that to google code. I've tried adding in a new file called key.ino

Use the Arduino GUI to create a new tab called key.h, put your defines there. In your main module,

#include "Defines.h"

"Defines.h" for different LCD pinouts that looks like:

// defines associated specifically with Nokia 5110 LCD ScrnFuncts
#define PIN_SCE   7
#define PIN_RESET 6
#define PIN_DC    5
#define PIN_SDIN  4
#define PIN_SCLK  3

#define LCD_C     LOW
#define LCD_D     HIGH
#define LCD_X     84
#define LCD_Y     48

Or even better

#include "key.h"

Thanks guys - working perfectly now.