[vlc-devel] [PATCH 0/6] Fix warnings related to unknown attributes by introducing VLC_ATTR

Filip Roséen filip at atch.se
Sun Feb 26 20:13:10 CET 2017


After the more than welcomed commit linked below we currently
experience tons of diagnostics related to unknown attributes when
things are compiled with clang.

 - http://git.videolan.org/?p=vlc.git;a=commit;h=97d669a8c704a19f9bd4cd4b8f995dcc9e9edbb7

Example:

    include/vlc_threads.h:837:16: warning: unknown attribute 'error' ignored [-Wunknown-attributes]
    __attribute__((error("sorry, cannot sleep for such short a time")))
                   ^
    include/vlc_threads.h:847:16: warning: unknown attribute 'warning' ignored [-Wunknown-attributes]
    __attribute__((warning("use proper event handling instead of short delay")))
                   ^
Rationale for changes
----------------------------------------------------------------------

As attribute usage is encouraged in cases where it make sense, I was
reluctant to wrap usage of the affected attributes in a preprocessor
condition checking if we are being compiled by clang, and what version
of clang.

In my opinion that would lead to unnecessary complexity and harder
maintainability, especially when things differ version to version.

Instead these changes include addition of support for checking
supported attributes during configure, as well as a macro named
`VLC_ATTR` that is used to apply the checked attributes (if they are
supported by the compiler, otherwise it expands to an empty string).

Future
----------------------------------------------------------------------

I currently have patches that does what is listed below, but will
submit them at a later time if the contents of this patch-batch is
satisfactory:

 - replace usage of VLC_DEPRECATED with VLC_ATTR(deprecated)

 - add support for more attributes that can be used to further
   strengthen the codebase (where applicable)

 - some further attribute related clean-up

Disclaimer
----------------------------------------------------------------------

I took about an hour to read up on `.m4` and `autoconf` prior to
writing that part of the changes; besides reading patches to this
codebase, that hour is my **only** experience with the toolchain.

Please go easy on me if there is something that should have been done
differently.

Best Regards,\

Filip Roséen (6):
  m4: add attributes.m4
  configure: add check for attributes
  configure: use attributes.m4 to check for attribute packed
  configure: use attributes.m4 to check for attribute aligned
  vlc_common: introduce macro VLC_ATTR
  vlc_threads: use VLC_ATTR to apply attributes

 configure.ac          | 25 ++++++++++---------------
 include/vlc_common.h  | 33 +++++++++++++++++++++++++++++++++
 include/vlc_threads.h | 20 +++++++++++---------
 m4/Makefile.am        |  1 +
 m4/attributes.m4      | 41 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 96 insertions(+), 24 deletions(-)
 create mode 100644 m4/attributes.m4

-- 
2.11.1



More information about the vlc-devel mailing list