From: fred AT genesis DOT demon DOT co DOT uk (Lawrence Kirby) Newsgroups: comp.os.msdos.djgpp,comp.lang.c Subject: Re: Can't get external variables to work!?? Date: Sat, 07 Feb 98 20:02:24 GMT Organization: none Message-ID: <886881744snz@genesis.demon.co.uk> References: <34DC7457 DOT 6A0A7521 AT iafrica DOT com> <34DCAE69 DOT F64D9DCE AT acm DOT org> Reply-To: fred AT genesis DOT demon DOT co DOT uk Lines: 31 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk In article <34DCAE69 DOT F64D9DCE AT acm DOT org> petebecker AT acm DOT org "Pete Becker" writes: >James Hu wrote: >> >> This problem could have been diagnosed if you had #include'd kbd.h into >> kbd.c. > >Well, no. It's perfectly legal to have an extern declaration followed by >a static definition. According to 6.1.2.2 it results in undefined behaviour: "If, within a translation unit, the same identifier appears with both internal and external linkage, the behaviour is undefined." However as far as I can see no diagnostic is required. >So the compiler is not required to say anything if >you do this. I suppose it's possible that some compiler might give you a >warning because it thinks that you may have made a mistake, but I don't >know of one that does this. gcc -pedantic does (so presumably DJGPP does too). The other 2 compilers I have on this (Unix) platform do too if you put them in ANSI C mode. -- ----------------------------------------- Lawrence Kirby | fred AT genesis DOT demon DOT co DOT uk Wilts, England | 70734 DOT 126 AT compuserve DOT com -----------------------------------------