delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/08/05/19:31:22

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Message-ID: <4112BE04.3B151CA1@yahoo.com>
From: CBFalconer <cbfalconer AT yahoo DOT com>
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: <cepqfs$jts AT odak26 DOT prod DOT google DOT com> <vY6Qc.33228$vX4 DOT 11673 AT cyclops DOT nntpserver DOT com> <41115A5F DOT 7DDC6318 AT yahoo DOT com> <bNtQc.58210$vX4 DOT 56203 AT cyclops DOT nntpserver DOT com> <41127AF9 DOT 26DEA37C AT yahoo DOT com>
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 <stdio.h>
>>
>> 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019