as a general convention, interfaces go in header files and implementations go in the actual .c files.
If you have these three files:
HeaderTest.h
Code:
int* intptrarr[1000];
#define NULL 0
void fn()
{
intptrarr[0] = NULL;
}
void Module2();
HeaderTest.cpp
Code:
#include "HeaderTest.h"
int main()
{
fn();
return 0;
}
Module2.cpp
Code:
#include "HeaderTest.h"
void Module2()
{
fn();
}
When attempting to compile this program with Visual C++, I get the following error messages:
--------------------Configuration: HeaderTest - Win32 Debug--------------------
Compiling...
HeaderTest.cpp
Module2.cpp
Linking...
Module2.obj : error LNK2005: "void __cdecl fn(void)" (?fn@@YAXXZ) already defined in HeaderTest.obj
Module2.obj : error LNK2005: "int * * intptrarr" (?intptrarr@@3PAPAHA) already defined in HeaderTest.obj
Debug/HeaderTest.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
HeaderTest.exe - 3 error(s), 0 warning(s)