X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f Message-ID: <411A0EEF.F3DA04B4@yahoo.com> Date: Wed, 11 Aug 2004 08:19:59 -0400 From: CBFalconer 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: <10408102240 DOT AA89930 AT clio DOT rice DOT edu> <2719-Wed11Aug2004065357+0300-eliz AT gnu DOT org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Eli Zaretskii wrote: >> From: sandmann AT clio DOT rice DOT edu (Charles Sandmann) >> >> 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. Just thinking out loud. That means that, within main only, and in the DJGPP stack environment, the system has to translate the word 'environ' to access the space for a third parameter to main. This is in the compiler proper. That access has to be removed if the -ansi directive is in force. After that, the presence or absence of environ in the names resolved by the library is not germane, provided the resolution involves only a separate module so that it will not be loaded if not already resolved. The fact that the runtime loads a third parameter value for main does not matter, since it is no more programmatically accessible than is the stack marker (return address, etc.). However if main is declared with a third parameter, under any name, the normal mechanisms will provide access to it. i.e. the thing to disable, under -ansi, is specifying that third parameter in the main header. Then gcc -ansi will barf if, in a main, it finds: int main(int, char **, anything) Thus the library proper is not affected, and can supply any names desired in either user or system space, provided they are in separate modules and not loaded unless specified. The whole thing is therefore a GCC bug, not a library bug. -- "Churchill and Bush can both be considered wartime leaders, just as Secretariat and Mr Ed were both horses." - James Rhodes. "A man who is right every time is not likely to do very much." - Francis Crick, co-discover of DNA