grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Disable -Werror when error attribute generates warnings


From: Vladimir 'φ-coder/phcoder' Serbinenko
Subject: Re: Disable -Werror when error attribute generates warnings
Date: Sat, 02 Jan 2010 19:21:21 +0100
User-agent: Mozilla-Thunderbird 2.0.0.22 (X11/20091109)

>  =20
>> With an older version of gcc that does not understand the error =20
>> attribute, gcc generates warnings when compiling files that include =20
>> include/grub/list.h.  Since TARGET_CFLAGS contains -Werror by default,=
 =20
>> the build of modules fails.
>>
>> The following patch checks whether the C compiler supports the error  =

>> attribute without warning, and disables -Werror if that is not the cas=
e =20
>> (as otherwise the build will fail).
>>    =20
>
> Instead of this, why not only use the attribute if it's available? I
> couldn't find an entry about it in GCC's human-readable change
> summaries, but support was committed on 2007-09-23 so I think it's
> available from GCC 4.3.
>
>  =20
Why not have configure.ac check specifically if this attribute is
available and use it only if it is?
> I use this GNUC_PREREQ approach in other projects and rather like it. I=
t
> could be extended to cover our other uses of attributes quite easily.
>
> 2010-01-02  Colin Watson  <address@hidden>
>
>       * include/grub/misc.h (GNUC_PREREQ): New macro.
>         (ATTRIBUTE_ERROR): New macro.
>         * include/grub/list.h (grub_bad_type_cast_real): Use
>         ATTRIBUTE_ERROR.
>
> =3D=3D=3D modified file 'include/grub/list.h'
> --- include/grub/list.h       2009-12-31 14:03:09 +0000
> +++ include/grub/list.h       2010-01-02 15:31:44 +0000
> @@ -42,7 +42,7 @@ void EXPORT_FUNC(grub_list_insert) (grub
> =20
>  static inline void *
>  grub_bad_type_cast_real (int line, const char *file)
> -     __attribute__ ((error ("bad type cast between incompatible grub t=
ypes")));
> +     ATTRIBUTE_ERROR ("bad type cast between incompatible grub types")=
;
> =20
>  static inline void *
>  grub_bad_type_cast_real (int line, const char *file)
>
> =3D=3D=3D modified file 'include/grub/misc.h'
> --- include/grub/misc.h       2009-12-18 02:57:32 +0000
> +++ include/grub/misc.h       2010-01-02 15:31:31 +0000
> @@ -25,6 +25,22 @@
>  #include <grub/symbol.h>
>  #include <grub/err.h>
> =20
> +/* GCC version checking borrowed from glibc. */
> +#if defined(__GNUC__) && defined(__GNUC_MINOR__)
> +#  define GNUC_PREREQ(maj,min) \
> +     ((__GNUC__ << 16) + __GNUC_MINOR__ >=3D ((maj) << 16) + (min))
> +#else
> +#  define GNUC_PREREQ(maj,min) 0
> +#endif
> +
> +/* Does this compiler support compile-time error attributes? */
> +#if GNUC_PREREQ(4,3)
> +#  define ATTRIBUTE_ERROR(msg) \
> +     __attribute__ ((__error__ (msg)))
> +#else
> +#  define ATTRIBUTE_ERROR(msg)
> +#endif
> +
>  #define ALIGN_UP(addr, align) \
>       ((addr + (typeof (addr)) align - 1) & ~((typeof (addr)) align - 1))
>  #define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
>
>  =20


--=20
Regards
Vladimir '=CF=86-coder/phcoder' Serbinenko


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]