Going through the RPC tutorial at MSDN,
I have just created a project with two .c
files as following::
/* file hellop.c */
#include <stdio.h>
#include <windows.h>
void HelloProc(char * pszString)
{
printf("%s\n", pszString);
return ;
}
and
/* file: hello.c */
#include "hellop.c"
void main(void)
{
char * pszString = "Hello, World";
HelloProc(pszString);
return ;
}
Problem:: Error LNK2005 and fatal Error LNK1169
Why and where is the compiler seeing the multiple symbol definition or declaration of HelloProc(char*)
?
EDIT:: As concluded in this SO_Question, including .h
file is the best solution obviously. But does that leave us with no implementation of design where we can include a .c
file into another .c
file?
Weird Behavior:: First time compilation runs fine but rebuild of solution breaks with the above mentioned errors. You can check the multiple first time compilation by changing the file name from .c
to .cpp
and vice-versa. Why does it exhibit this behavior? (I am not sure if anybody else have also experienced this with the given example)