This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
why are stdin, stdout, stderr const?
- From: Ian Gilmour <ian dot gilmour at ffei dot co dot uk>
- To: ecos-discuss at ecos dot sourceware dot org
- Date: Fri, 3 Sep 2004 09:28:02 +0100 (BST)
- Subject: [ECOS] why are stdin, stdout, stderr const?
Our system runs a simple monitor which is also used to generate error logs, via a simple redirection of stdout/stderr to a ram file.
i.e.
// Open a ram file to buffer the stdout and stderr
// Redirect stdout and stderr to our ram buffer
if ((m_ramfd = open("/ram/stdout", O_WRONLY)) >= 0) {
StdoutStream = new Cyg_StdioStream(m_ramfd, Cyg_StdioStream::CYG_STREAM_WRITE, false, false, _IOLBF);
// Preserve existing stdio
termstdout = stdout;
termstderr = stderr;
// Redirect to ram buffer
stdout = (FILE *)StdoutStream;
stderr = (FILE *)StdoutStream;
}
The above works fine with rodata located in ram, but fails when I modify the locate script to place all readonly data in flash, because stdin, stdout and stderr are located in rodata.
I can fix it by removing the 'const's from the stdin/stdout/stderr declarations in stdin.cxx, stdout.cxx, and stderr.cxx.
But why are they there in the first place?
Or should I be doing this via some other method?
cheers,
Ian
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss