How can i include and use function in multiple cpp files?
// my_function.h
void func_i_want_to_include();
// my_function.cpp
void func_i_want_to_include()
{
puts("hello world");
}
//main.cpp
#include "my_function.h"
#include "file_b.h"
int main()
{
call_to_file_b();
func_i_want_to_include();
return 0;
}
//file_b.h
void call_to_file_b();
//file_b.cpp
#include "my_function.h"
void call_to_file_b()
{
puts("from file b\n");
func_i_want_to_include();
}
When i do it like this i get yield by the linker "unresolve external symbol" , i guess the linker past func_i_want_to_include()
2 times instead of understand that this is the same function.
How do i tell him ' this is the same function just call it from 2 files but don't try to make 2 copies of the same function?