This is the mail archive of the
ecos-patches@sourceware.org
mailing list for the eCos project.
uSTL hello world (linker issue fix)
- From: Uwe Kindler <uwe_kindler at web dot de>
- To: ecos-patches at sourceware dot org
- Cc: jifl at jifvik dot org
- Date: Tue, 06 Oct 2009 11:13:50 +0200
- Subject: uSTL hello world (linker issue fix)
Hello,
according to the discussion on the ecos-discuss mailinglist
(http://ecos.sourceware.org/ml/ecos-discuss/2009-09/msg00259.html) I
created a patch that fixes the linker issue of the uSTL hello world example.
I tested the solution with differend configurations (-O0 and -O2) and it
worked all the time.
The second patch removes cout.flush() from the example because in my
last tests it worked well without cout.flush().
Uwe
diff -ruN ecos_web_cvs/ecos/packages/infra/current/ChangeLog ecos/ecos/packages/infra/current/ChangeLog
--- ecos_web_cvs/ecos/packages/infra/current/ChangeLog 2009-02-14 04:15:14.000000000 +0100
+++ ecos/ecos/packages/infra/current/ChangeLog 2009-10-06 10:47:20.906250000 +0200
@@ -1,3 +1,9 @@
+2009-10-06 Uwe Kindler <uwe_kindler@web.de>
+
+ * include/cyg_type.h: Changed definition of macro
+ CYG_REFERENCE_OBJECT according to proposal of Bart Veer on
+ ecos-discuss mailing list.
+
2009-02-14 Jonathan Larmour <jifl@eCosCentric.com>
* tests/cxxsupp.cxx (cyg_start): Only test 'new' with ARM tools after
diff -ruN ecos_web_cvs/ecos/packages/infra/current/include/cyg_type.h ecos/ecos/packages/infra/current/include/cyg_type.h
--- ecos_web_cvs/ecos/packages/infra/current/include/cyg_type.h 2009-02-04 17:59:41.000000000 +0100
+++ ecos/ecos/packages/infra/current/include/cyg_type.h 2009-10-06 10:34:50.406250000 +0200
@@ -196,15 +196,16 @@
CYG_MACRO_END
-// -------------------------------------------------------------------------
-// Reference a symbol without explicitly making use of it. Ensures that
-// the object containing the symbol will be included when linking.
-
-#define CYG_REFERENCE_OBJECT(__object__) \
- CYG_MACRO_START \
- static void *__cygvar_discard_me__ __attribute__ ((unused)) = \
- &(__object__); \
- CYG_MACRO_END
+//----------------------------------------------------------------------------
+// The unused attribute stops the compiler warning about the variable
+// not being used.
+// The used attribute prevents the compiler from optimizing it away.
+
+#define CYG_REFERENCE_OBJECT(__object__) \
+ CYG_MACRO_START \
+ static const void* __cygvar_discard_me__ \
+ __attribute__ ((unused, used)) = (const void*)&(__object__); \
+ CYG_MACRO_END
// -------------------------------------------------------------------------
// Define basic types for using integers in memory and structures;
diff -ruN ecos_web_cvs/ecos/packages/language/cxx/ustl/current/ChangeLog ecos/ecos/packages/language/cxx/ustl/current/ChangeLog
--- ecos_web_cvs/ecos/packages/language/cxx/ustl/current/ChangeLog 2009-08-31 08:06:44.906250000 +0200
+++ ecos/ecos/packages/language/cxx/ustl/current/ChangeLog 2009-10-06 10:25:35.671875000 +0200
@@ -1,3 +1,7 @@
+2009-10-06 Uwe Kindler <uwe_kindler@web.de>
+ * doc/ustl.sgml: Removed cout.flush() from example and from note.
+ Added note about use of compiler flag -Wno-undef.
+
2009-08-30 John Dallaway <john@dallaway.org.uk>
* include/*.h: Move all headers to include/ustl/ except ustl.h and
diff -ruN ecos_web_cvs/ecos/packages/language/cxx/ustl/current/doc/ustl.sgml ecos/ecos/packages/language/cxx/ustl/current/doc/ustl.sgml
--- ecos_web_cvs/ecos/packages/language/cxx/ustl/current/doc/ustl.sgml 2009-08-27 11:00:12.000000000 +0200
+++ ecos/ecos/packages/language/cxx/ustl/current/doc/ustl.sgml 2009-10-06 10:13:37.250000000 +0200
@@ -118,7 +118,9 @@
<PARA>
To use uSTL in your eCos application, simply include the file
<filename><ustl.h></filename>. All uSTL classes are in the
-<varname>ustl</varname> namespace.
+<varname>ustl</varname> namespace. To prevent compiler warnings
+when compilig your eCos application with uSTL support you need to
+add the compiler flag <OPTION>-Wno-undef</OPTION>.
</PARA>
<PROGRAMLISTING>
@@ -128,7 +130,6 @@
int main (int argc, char* argv[])
{
cout << "Hello world!\n";
- cout.flush();
return EXIT_SUCCESS;
}
</PROGRAMLISTING>
@@ -136,9 +137,8 @@
<NOTE>
<PARA>
If you use <varname>cout</varname> for printing to the console,
-then data will be flushed only if you finish the output with
-<varname>endl</varname> or '\n' and then call
-<function>cout.flush()</function> as in the example above.
+then data will get sent only if you finish the output with
+<varname>endl</varname> or '\n'.
</PARA>
</NOTE>