changeset 2924:56796f529a99

* include/cyg_type.h: Changed definition of macro CYG_REFERENCE_OBJECT according to proposal of Bart Veer on ecos-discuss mailing list.
author jld
date Tue, 06 Oct 2009 12:34:55 +0000
parents a3997dc62092
children 7cbaadc92c67
files packages/infra/current/ChangeLog packages/infra/current/include/cyg_type.h
diffstat 2 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/packages/infra/current/ChangeLog
+++ b/packages/infra/current/ChangeLog
@@ -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
--- a/packages/infra/current/include/cyg_type.h
+++ b/packages/infra/current/include/cyg_type.h
@@ -196,15 +196,16 @@ typedef cyg_halbool bool;
 CYG_MACRO_END
 
 
-// -------------------------------------------------------------------------
-// Reference a symbol without explicitly making use of it. Ensures that
-// the object containing the symbol will be included when linking.
+//----------------------------------------------------------------------------
+// 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 void *__cygvar_discard_me__ __attribute__ ((unused)) =       \
-                                                          &(__object__); \
-     CYG_MACRO_END
+#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;