This is the mail archive of the
ecos-patches@sourceware.org
mailing list for the eCos project.
Re: mbox compiler warning fix
Andrew Lunn wrote:
I also tried the CYGBLD_ATTRIB_USED in other positions on the line and
nothing works.
UNUSED not USED. I don't know where __attribute__((used))
(CYGBLD_ATTRIB_USED) comes from. It's not documented in the GCC manuals
I've seen (4.1.1 or 3.4.6, for example, at http://gcc.gnu.org/onlinedocs/).
Ah, O.K.
<fx: Jifl smacks himself>
I thought there was a CYGBLD_ATTRIB_UNUSED macro, but evidently not! Can
you try tweaking the definition of CYGBLD_ATTRIB_USED so it only uses
__attribute__((unused)) and see if that fixes things?
I've now found a reference to __attribute__((used)) and it is a function
attribute i.e. only for labelling a function itself to indicate if that
function is or is not used. The only user of it I can see is
hal/common/current/include/hal_tables.h.
I'm not sure __attribute__((unused)) is functionally different though. For
functions, the GCC docs say:
`unused'
This attribute, attached to a function, means that the function is
meant to be possibly unused. GCC will not produce a warning for
this function.
`used'
This attribute, attached to a function, means that code must be
emitted for the function even if it appears that the function is
not referenced. This is useful, for example, when the function is
referenced only in inline assembly.
I would expect that GCC will emit code for the function even with
__attribute__((unused)).
But if not, then maybe we should add a CYGBLD_ATTRIB_VAR_UNUSED macro
instead, to cope with uninitialised variables, and would map solely to
__attribute__((unused)).
Well, we don't have CYGBLD_ATTRIB_UNUSED in cyg_type.h. What we have is
# if !defined(CYGBLD_ATTRIB_USED)
# if __GNUC_VERSION__ >= 30302
# define CYGBLD_ATTRIB_USED __attribute__((used))
# else
# define CYGBLD_ATTRIB_USED __attribute__((unused))
# endif
# endif
This tells the compiler that a variable is used, or at least it should
not complain about it not being used. Typically this is for #ifdef
out code, yet the variable declarations still exist.
Ideally you should also ifdef out the variables in that case - otherwise
they'll take up space, admittedly only on stack. You do sometimes need this
attribute in some cases though.
However the warning im getting is different. Its about passing an
uninitialised variable to a function.
Is CYGBLD_ATTRIB_UNUSED something eCosCentric have added to there
private branch?
Nope. Just my brain fart.
Jifl
--
eCosCentric http://www.eCosCentric.com/ The eCos and RedBoot experts
Company legal info, address and number: http://www.ecoscentric.com/legal
------["The best things in life aren't things."]------ Opinions==mine