From: Andrew Crabtree Message-Id: <199703290427.AA038159623@typhoon.rose.hp.com> Subject: Re: Multiple-file problem To: deltaman AT swipnet DOT se Date: Fri, 28 Mar 1997 20:27:03 PST Cc: djgpp AT delorie DOT com In-Reply-To: <333C3C43.7216@geocities.com>; from "Deltaman" at Mar 28, 97 10:46 pm > In 'somefunc.c' I include 'header.h' and 'mainprog.c' and in > 'mainprog.c' I include 'header.h'. It compiles perfectly (in RHIDE) but > when I links it I get the error messages: > > mainprog.c(a number) Error: multiple definition of > somefunc.c(same number) Error: first defined here > > This happens with all functions (even main) in 'mainprog.c'. What should > I do to make it work? As people in comp.lang.c love to point out you should use int main not void main. But, onto your problem. I think in general there is never a reason to #include a C file. You are compiling the same source twice which causes the linker to complain when it sees two copies of everything. Your .h file should contain the following. Function prototypes Extern variable declarations #defines #includes Just include this and you should be fine. Andrew