Bug 3137 - FILE *stdin, *stdout, *stderr are not constant in stdio.h
Summary: FILE *stdin, *stdout, *stderr are not constant in stdio.h
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 6.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Cristian Gafton
QA Contact:
URL:
Whiteboard:
: 3253 3742 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 1999-05-29 03:49 UTC by Damien, Miller
Modified: 2008-05-01 15:37 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 1999-05-29 13:59:05 UTC
Embargoed:


Attachments (Terms of Use)

Description Damien, Miller 1999-05-29 03:49:58 UTC
FILE *stdin, *stdout, *stderr are no longer declared
constant in stdio.h. They have been constant in previous
versions of RHL (as well as just about every other OS on the
planet).

This breaks all sorts of code. A trivial example:

---------------

#include <stdio.h>

FILE *logf = stderr;

int main(void)
{
	fprintf(logf, "This bites.\n");
}

---------------

Comment 1 Jeff Johnson 1999-05-29 13:59:59 UTC
Yes, glibc-2.1 requires programs to be re-written as below. Some
of the internals of the stdio structures have changed making
compatibility with glibc-2.0 more problematic than it would be
otherwise. The change below permits the loader to fix certain of
these problems and prevents the situation from happening again.
(At least I think that's the correct explanation ...)

#include <stdio.h>

FILE *logf;

int main(void)
{
	logf = stderr;
        fprintf(logf, "This bites.\n");
}

Comment 2 Jeff Johnson 1999-06-03 20:34:59 UTC
*** Bug 3253 has been marked as a duplicate of this bug. ***

In glibc-devel-2.1.1-6 a gratuitous change to
stdio.h/libio.h was made which prevents stdin, stderr and
stdout from being used as initializers.

The code below complies on every system I've tried *except*
the latest glibc-devel-2.1.1.

#include <stdio.h>
FILE *x = stdout;

An (unnacceptable) workaround is to use
_IO_stdout.

Comment 3 Jeff Johnson 1999-06-26 13:53:59 UTC
*** Bug 3742 has been marked as a duplicate of this bug. ***

The change of stderr in the standard include file
/usr/include/stdio.h from #define stderr _IO_stderr in
Redhat 5.2 to:

extern FILE *stderr

in Rh 6.0 may cause problems in older programs that expect
the normal definition for stderr.


Note You need to log in before you can comment on or make changes to this bug.