Mail Archives: djgpp/2004/08/05/19:31:22
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 -