Difference between revisions of "Multi-source"
From emboxit
m (1 revision) |
|
(No difference)
|
Latest revision as of 16:51, 11 September 2015
C
Standard way
MyLib.c:
int Variable;
MyLib.h:
extern int Variable;
main.c:
#include "MyLib.h" int main(void) { Variable = 10; printf("%d\n", Variable); return 0; }
Simple way (proposed by Th.P.)
- Place c code inside files with names like spi_cpp.h
- #include spi_cpp.h inside the (main).cpp
- .h files are not compiled as individual files
- Compiler 'sees' a single source file
- Compilers today are fast, so usually no problem with compile time