I just noticed that in the file Test.c and i2c_C.c I #include "i2c_C.h", but nowhere does i2c_C.h reference i2c_C.c. So surely when I call a function from Test.c that is in i2c_C.c, it looks at the i2c_C.h file to see the declaration of the function, but how does it know when the function actually is?
Edit:
OK, I just got it working, is this how it should be done?
- Original i2c_C.h and i2c_C.c files compiled and working
- Now to be able to use the functions I created in i2c_C.c, I copied the code into i2c_c.h
- Now Test.h and Test.c have been created and #include i2c_C.h
- I can now call the function 'wait()' from Test.c
Is that correct. I need to create some working code, and then when happy with it, put it all in the header file to be able to use it from another project?
Sorry to sound so stupid, but people can only learn from wiser and more experienced people like yourselves.
Also, what is all this about in the h files that XC8 creates:
Edit:
OK, I just got it working, is this how it should be done?
- Original i2c_C.h and i2c_C.c files compiled and working
- Now to be able to use the functions I created in i2c_C.c, I copied the code into i2c_c.h
- Now Test.h and Test.c have been created and #include i2c_C.h
- I can now call the function 'wait()' from Test.c
Is that correct. I need to create some working code, and then when happy with it, put it all in the header file to be able to use it from another project?
Sorry to sound so stupid, but people can only learn from wiser and more experienced people like yourselves.
Also, what is all this about in the h files that XC8 creates:
Rich (BB code):
#ifndef TEST_H
#define TEST_H
...........I am currently putting all my defines, pragmas etc. here, is this the correct place to put them? It seem to work if I put them here, or right at the top.
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* TEST_H */
Last edited: