[ECOS] Re: uSTL hello world
cetoni GmbH - Uwe Kindler
Tue Sep 1 08:36:00 GMT 2009
> 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.
int main (int argc, char* argv)
cout << "Hello world!\n";
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:
ifstream cin (STDIN_FILENO);
ofstream cout (STDOUT_FILENO);
ofstream cerr (STDERR_FILENO);
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.
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
More information about the Ecos-discuss