# HG changeset patch # User jld # Date 1254832495 0 # Node ID 56796f529a9979217d0258bf7059b882b2777c65 # Parent a3997dc62092386fd73c4cb3e58342cfde2cf3cc * include/cyg_type.h: Changed definition of macro CYG_REFERENCE_OBJECT according to proposal of Bart Veer on ecos-discuss mailing list. diff --git a/packages/infra/current/ChangeLog b/packages/infra/current/ChangeLog --- a/packages/infra/current/ChangeLog +++ b/packages/infra/current/ChangeLog @@ -1,3 +1,9 @@ +2009-10-06 Uwe Kindler + + * 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 * tests/cxxsupp.cxx (cyg_start): Only test 'new' with ARM tools after diff --git a/packages/infra/current/include/cyg_type.h b/packages/infra/current/include/cyg_type.h --- 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;