In /usr/include (for stderr) In Redhat 5.2 we have: extern FILE *stdin, *stdout, *stderr; /* TODO */ #define stdout _IO_stdout However in Redhat 6.0 extern FILE *stderr; /* Standard error output stream. */ This is causing a problem for the code fragment: FILE *dsErrOutput_p = stderr; This works on other platforms as stderr is defined. Checking with the ANSI standards thsi should be OK. Does this repesent a change in how IO is handled in this and future versions of Redhat or is this just an oversight? We are working on a large software package and are trying to port our linux versions to Redhat 6.0 (and higher). Currently our software works fine on Redhat 5.2. Jim Overly Harvard-Smithsonian Center for Astrophysics
You cannot statically initialize something as std(err|out|in); this is a change with glibc-2.1. From the glibc FAQ: 3.9. I get compiler messages "Initializer element not constant" with stdin/stdout/stderr. Why? {RM,AJ} Constructs like: static FILE *InPtr = stdin; lead to this message. This is correct behaviour with glibc since stdin is not a constant expression. Please note that a strict reading of ISO C does not allow above constructs. One of the advantages of this is that you can assign to stdin, stdout, and stderr just like any other global variable (e.g. `stdout = my_stream;'), which can be very useful with custom streams that you can write with libio (but beware this is not necessarily portable). The reason to implement it this way were versioning problems with the size of the FILE structure. To fix those programs you've got to initialize the variable at run time. This can be done, e.g. in main, like: static FILE *InPtr; int main(void) { InPtr = stdin; } or by constructors (beware this is gcc specific): static FILE *InPtr; static void inPtr_construct (void) __attribute__((constructor)); static void inPtr_construct (void) { InPtr = stdin; }