X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Trace-PostClient-IP: 68.147.131.211 From: Brian Inglis Newsgroups: comp.os.msdos.djgpp Subject: Re: Environment Variables Organization: Systematic Software Message-ID: References: <41115A5F DOT 7DDC6318 AT yahoo DOT com> <41127AF9 DOT 26DEA37C AT yahoo DOT com> <4112BE04 DOT 3B151CA1 AT yahoo DOT com> <7494-Fri06Aug2004121205+0300-eliz AT gnu DOT org> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 65 Date: Fri, 06 Aug 2004 19:57:39 GMT NNTP-Posting-Host: 24.71.223.147 X-Complaints-To: abuse AT shaw DOT ca X-Trace: pd7tw3no 1091822259 24.71.223.147 (Fri, 06 Aug 2004 13:57:39 MDT) NNTP-Posting-Date: Fri, 06 Aug 2004 13:57:39 MDT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Fri, 06 Aug 2004 12:12:06 +0300 in comp.os.msdos.djgpp, "Eli Zaretskii" wrote: >> From: CBFalconer >> Newsgroups: comp.lang.c,comp.os.msdos.djgpp >> Date: Thu, 05 Aug 2004 23:27:28 GMT >> >> 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'. > >`environ' is a symbol that comes from the library. It is a pointer to >an array of char *, where each array element is a string of the form >"foo=bar": these are the environment variables and their values. > >I guess if this happens even under "-ansi -pedantic", it's a bug that >we pollute the ANSI namespace with a non-ANSI symbol that doesn't bgin >with an underscore. But given that Unix programs expect that symbol, >I'm not sure we can change that. FWIW below is a list of library symbols that pollute the user global namespace in *ALL* C programs and are not mentioned in the libc documentation. It was produced by compiling and linking a small dummy program, then running nm -Cg, stripping the addresses, and editing out the documented names. The first letter tells you whether it's defined in a text, data or bss segment. D djgpp_first_ctor D djgpp_first_dtor D djgpp_last_ctor D djgpp_last_dtor D edata B end B environ T etext B exception_stack T start ISTM that a reasonable first step would be to document the existence of these symbols in the libc documentation, and possibly add useful public interfaces to some header file, perhaps only for the case of environ, which seems to be the only symbol likely to be accessed by user level code. A useful place for at least defining environ so that it could at least be found in a header file might be in .../include/libc/environ.h between the ANSI and POSIX excludes [1], unless _POSIX_SOURCE has to be defined to include it, in which case [2]: #ifndef __STRICT_ANSI__ extern char **environ; [1] #ifndef _POSIX_SOURCE extern char **environ; [2] -- Thanks. Take care, Brian Inglis Calgary, Alberta, Canada Brian DOT Inglis AT CSi DOT com (Brian dot Inglis at SystematicSw dot ab dot ca) fake address use address above to reply