From: "DeHackEd" Newsgroups: comp.os.msdos.djgpp References: <37245860 DOT 11385716 AT 158 DOT 152 DOT 254 DOT 70> Subject: Re: Header files Lines: 63 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2014.211 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 Message-ID: Date: Sun, 25 Apr 1999 20:19:55 GMT NNTP-Posting-Host: 142.194.222.192 X-Trace: tundra.ops.attcanada.net 925071595 142.194.222.192 (Sun, 25 Apr 1999 20:19:55 GMT) NNTP-Posting-Date: Sun, 25 Apr 1999 20:19:55 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com wrote in message news:37245860 DOT 11385716 AT 158 DOT 152 DOT 254 DOT 70... > I just don't get header files and what "extern" actually means. I want Ok, here's the way it works. The following are 2 declarations of a variable: // This line can only show up in exactly 1 C file int foo; // This line can show up anywhere, and is merely informative extern int foo; // This is illegal extern int foo = 27; If you say extern, then the compiler knows it does exist but not here. If you don't use extern, it's actually declared. If you declare it in more than 1 file, the linker rejects it. > to break up a long program, so I've put all the declarations, from the > first #define up til main(), into a .h file. > > I've put some of the functions into one .C file, and the rest into > another, and included my .h file in both. > > It gives me "multiple definition of blablah" a lot of times. Remeber that the H file contains the word extern and only 1 C file contains the real declaration. Both EXTERN and actually declaring the variable in the same file (or including it) will not conflict or cause errors. > > What do I actually do, what does extern mean? I realise it's simple > but it's a big project and I don't want to mess anything up then have > some obscure bug pop up later and torment me not knowing what it is. You're just modifying a project right? As long as you don't modify the actual code, you have nothing to worry about so long as the linker accepts the file and does not give errors. > ------------------------------------------------------------------------ > well I try my best, to be just like I am > but everybody wants you to be jeeeiiiist like them > they say "sing while you slave", but I just get bored, > > http://www.greenaum.demon.co.uk/ > > Protect privacy, boycott Intel: http://www.bigbrotherinside.org Now this I have got to see. -- "DeHackEd" My Email address in the header is fake (spammers). Email me at this address: http://www.geocities.com/cgi-bin/homestead/mail.pl?dehacked