public inbox for ecos-patches@sourceware.org
 help / color / mirror / Atom feed
* uSTL hello world (linker issue fix)
@ 2009-10-06  9:14 Uwe Kindler
  2009-10-06 12:28 ` John Dallaway
  0 siblings, 1 reply; 2+ messages in thread
From: Uwe Kindler @ 2009-10-06  9:14 UTC (permalink / raw)
  To: ecos-patches; +Cc: jifl

[-- Attachment #1: Type: text/plain, Size: 436 bytes --]

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

[-- Attachment #2: ecos_infra.patch --]
[-- Type: text/plain, Size: 2210 bytes --]

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;

[-- Attachment #3: ustl_doc.patch --]
[-- Type: text/plain, Size: 1933 bytes --]

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>&lt;ustl.h&gt;</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 &lt;&lt; "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>
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: uSTL hello world (linker issue fix)
  2009-10-06  9:14 uSTL hello world (linker issue fix) Uwe Kindler
@ 2009-10-06 12:28 ` John Dallaway
  0 siblings, 0 replies; 2+ messages in thread
From: John Dallaway @ 2009-10-06 12:28 UTC (permalink / raw)
  To: Uwe Kindler; +Cc: ecos-patches

Hi Uwe

Uwe Kindler wrote:

> 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.

Thank you for the patch. I have verified that the new definition of
CYG_REFERENCE_OBJECT() is compatible with the older eCos toolchain (GCC
3.2.1) so I will check this in.

From your description, it would appear that moving the lines:

    CYG_REFERENCE_OBJECT(stdin);
    CYG_REFERENCE_OBJECT(stdout);
    CYG_REFERENCE_OBJECT(stderr);

from open() to cyg_fd_init() is not now necessary for correct behaviour
of the minimal uSTL hello world application. However, it may or may not
be sensible to make this change anyway. I will leave this to Jifl/Nick.

John Dallaway

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-10-06 12:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-06  9:14 uSTL hello world (linker issue fix) Uwe Kindler
2009-10-06 12:28 ` John Dallaway

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).