Mail Archives: djgpp/2004/08/06/16:01:12
On Fri, 06 Aug 2004 12:12:06 +0300 in comp.os.msdos.djgpp, "Eli
Zaretskii" <eliz AT gnu DOT org> wrote:
>> From: CBFalconer <cbfalconer AT yahoo DOT com>
>> 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
- Raw text -