I have 3 files in a Visual Studio project: test.cpp
, date.cpp
and main.cpp
-
test.cpp:
int g() { return 0; }
date.cpp:
/*totally empty*/
main.cpp:
#include "test.cpp"
#include "date.cpp"
int main() { return g(); }
I understand that defining functions in a header file leads to violation of One-Definition Rule if header file is called multiple times. But here, I am calling it only once from only one file/translation unit. Why is it still throwing LNK2005?