www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2004/08/13/01:14:43

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
Message-ID: <411C4D77.A09F108B@yahoo.com>
Date: Fri, 13 Aug 2004 01:11:19 -0400
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
To: djgpp-workers AT delorie DOT com
Subject: Re: Fix for environ pollution
References: <10408121516 DOT AA22369 AT clio DOT rice DOT edu>
Reply-To: djgpp-workers AT delorie DOT com

Charles Sandmann wrote:
> 
>>> Instead of putting environ in djgpp.djl, could we use a define
>>> statement in a header outside the ansi and posix definitions?
>>
>> I think we cannot do this because Posix explicitly says that
>> environ is not declared in any header.
>>
>> In other words, a Posix program that uses environ is not
>> required to include any system header, and it still can expect
>> environ to be available.
> 
> OK, so Posix insists it be there without declaration, but ansi
> says it shouldn't be there ... It seems PROVIDE is the only fix.

But without -ansi (or -std=C99) it is perfectly allowable.  It
doesn't need to show up as a global, but only as a third parameter
to main, i.e. as local to main.  I still claim the library proper
is inconsequential.  It just shouldn't pollute.  So the name
change to _environ will do that, and environ never need be defined
in the library modules.

The run time doesn't know, or need to know, how many parameters
main was declared with.  It just places one integer and two
pointers on the stack before calling main.  Their names are
whatever the program writer placed in the line "int main(....){"

The point is that 'environ' is not in static storage, it is only
in the parameter list of main, under any name you like.  Or not.

-- 
Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT worldnet DOT att DOT net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!

- Raw text -


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