Say I have a header file, a.h
and b.cpp, c.cpp, both needs to use this function.Code:#ifndef A_H #define A_H int some_util_function() { ... } #endif
If I compile them separately then link them, I get a multiple definitions error.
What's the standard way to fix this? (Except moving it to another .c)Code:gcc -c b.cpp gcc -c c.cpp gcc b.o c.o #multiple definitions