This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: uSTL hello world
- From: cetoni GmbH - Uwe Kindler <uwe dot kindler at cetoni dot de>
- To: John Dallaway <john at dallaway dot org dot uk>
- Cc: ecos-discuss at sourceware dot org
- Date: Tue, 01 Sep 2009 10:36:24 +0200
- Subject: [ECOS] Re: uSTL hello world
- References: <4A97F60C.2030208@dallaway.org.uk>
Hi John,
There seems to be a problem with the uSTL hello world example given in
the uSTL documentation. The code produces no output. However, if I add a
printf() call after the cout.flush(), then I see _both_ messages.
This is not a case of printf() flushing the output - I can observe the
output from cout on the diagnostics channel _before_ the call to
printf() is made. In fact, if I move the printf() call to the start of
main(), then everything still works.
I can confirm this on my target. For me it smells like a linker issue. I
wrote the following main function from the example an added a test
function with a printf call that is not called from main.
void test()
{
printf("Hello printf2!\n");
}
int main (int argc, char* argv[])
{
cout << "Hello world!\n";
cout.flush();
return EXIT_SUCCESS;
}
If I execute main then I can see the output of cout. If I remove the
test function with the printf reference then the main function does not
print anything. So adding a printf reference makes cout working - so I
think this is a linker issue.
The stream objects are declared in the file ofstream.cpp:
#ifdef CYGVAR_USTL_CIN_COUT_CERR
ifstream cin (STDIN_FILENO);
ofstream cout (STDOUT_FILENO);
ofstream cerr (STDERR_FILENO);
#endif
For the creation of these objects there is no constructor priority set -
could this be the problem? Maybe the stream objects are created prior to
the creation of the libc stream objects. In the uSTL code there is no
explicit printf reference. It only uses vsnprintf.
Uwe
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss