X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Message-ID: <4112BE04.3B151CA1@yahoo.com> From: CBFalconer Organization: Ched Research X-Mailer: Mozilla 4.75 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.c,comp.os.msdos.djgpp Subject: Re: Environment Variables References: <41115A5F DOT 7DDC6318 AT yahoo DOT com> <41127AF9 DOT 26DEA37C AT yahoo DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 44 Date: Thu, 05 Aug 2004 23:27:28 GMT NNTP-Posting-Host: 12.76.129.24 X-Complaints-To: abuse AT worldnet DOT att DOT net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1091748448 12.76.129.24 (Thu, 05 Aug 2004 23:27:28 GMT) NNTP-Posting-Date: Thu, 05 Aug 2004 23:27:28 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com CBFalconer wrote: > Ralmin wrote: >> >> I thought of it another way... take for example this program: >> >> #include >> >> int environ; >> >> int main(void) >> { >> printf("%d\n", environ); >> return 0; >> } >> >> According to the standard, the above contains a definition of the >> variable environ, with external linkage and static storage, right? >> It should be therefore be initialised to zero. > > I agree with you, provided you use -ansi -pedantic. That prints a > non-zero value here under DJGPP 2.03 and gcc 3.2.1. Since you > have the problem under cygwin (I believe) and it doesn't appear to > be system library/header specific, I suggest YOU file a bug report > with gnu. "info gcc bugs" or "gcc --help" will tell you how to > file. > > I am cross-posting this to comp.os.msdos.djgpp. Changing the 'environ' name makes things become correct. gcc seems to be creating a parameter to main, which is being accessed by the identifier environ, even though the parameters are specified to be void. gcc -E creates no reference to 'environ'. I suspect there may be similar problems with argv and/or argc replacing environ in the same program. -- "I'm a war president. I make decisions here in the Oval Office in foreign policy matters with war on my mind." - Bush. "Churchill and Bush can both be considered wartime leaders, just as Secretariat and Mr Ed were both horses." - James Rhodes. "If I knew then what I know today, I would still have invaded Iraq. It was the right decision" - G.W. Bush, 2004-08-02