I believe I see what your saying, but I'm not sure it's quite what I need. I tired a couple more attempts, but no dice yet. I think this will help show the problem. I have been trying several things like using static, vs extern, vs not specified. This is how it is now, and I think this may show the problem.
In my-first-task.c#define _INCLUDE_AIS226
#include "../../hardware/LPC23XX/spi_acc_lpc_AIS226_2.h" // AIS226 accelerometer
#undef _INCLUDE_AIS226
blah blah blah
y_now = (signed short) fnSPI_AIS226(OUTY_L, SPI_READ, 0x00)
+ (signed short)((fnSPI_AIS226(OUTY_H, SPI_READ, 0x00) & HI_MASK) << 8);
In webinterface.c#define _INCLUDE_AIS226
#include "../../hardware/LPC23XX/spi_acc_lpc_AIS226_2.h" // AIS226 accelerometer
#undef _INCLUDE_AIS226
blah blah blah
y_now = (signed short) fnSPI_AIS226(OUTY_L, SPI_READ, 0x00)
+ (signed short)((fnSPI_AIS226(OUTY_H, SPI_READ, 0x00) & HI_MASK) << 8);
In spi_acc_lpc_AIS226_2.h#if defined _INCLUDE_AIS226 // include AIS chip
unsigned char fnSPI_AIS226(unsigned char cmd, unsigned char rw, unsigned char SPI_data){
unsigned long temp;
int temp2, null;
blah blah
return temp2;
}
#endif // stop including AIS chip
fnSPI_AIS226 is a function that sends 8 bits down the SPI and receives 8 bits from the SPI. Because I'm using it as my comm interface, I'm looking to call it from different c files as a kind of shared function. I tried using the #define and #undef to help limit the scope of when it's seen by the compiler, but it still complains "webInterface.obj : error LNK2005: _fnSPI_AIS226 already defined in my-first-task.obj"
I had expected that it would compile spi_acc_lpc_AIS226_2.h into an object file, as well as my-first-task.c and webinterface.c into their own object files. I expected my c file(s) would simply list a jump command in the object file and it would all come together during linking. But it appears it compiles a bit more literally. I understand that the #include will simply copy the specified file, replacing the include line when it's made into the object file. But I thought it would be a bit less literal than that. I was expecting it would copy just the jump command to the function, not the entire function.
I believe I would normally get around this by modifying my make file to specifically compile the .h file into the .o file, then I would make sure this .o file was a dependent of my-first-task and webinterface. It would then be included while linking and my functions would all pull together in the last compile step.