On Sat, Sep 10, 2016 at 10:55:21PM +0200, Armin Krezović wrote:
> clang doesn't support gnu_print attribute, so just
> leave it out when clang is used.
> 
> Signed-off-by: Armin Krezović <krezovic.ar...@gmail.com>
> ---
>  clients/stacking.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/clients/stacking.c b/clients/stacking.c
> index 4285a17..dd3d338 100644
> --- a/clients/stacking.c
> +++ b/clients/stacking.c
> @@ -184,7 +184,11 @@ fullscreen_handler(struct window *window, void *data)
>  
>  static void
>  draw_string(cairo_t *cr,
> +#ifndef __clang__
>              const char *fmt, ...) __attribute__((format (gnu_printf, 2, 3)));
> +#else
> +            const char *fmt, ...);
> +#endif

I would recommend avoiding structure elements (like `)` and `;`) in
#ifdef blocks, as some editors get confused by this.

I would also recommend avoiding code duplication, by moving the
__attribute__ to its own line and only #ifdef'ing that line.
(As a reminder, function attributes can also be added before the
function or between the return type and the function name, avoiding the
need for `;` to also be on its own line after the #ifdef).

But in this case, I think replacing `gnu_printf` with `printf` is
probably the best solution.
I was unable to find the difference between the two, though. Does anyone
know why one would want to use the gnu-prefixed version?

I also don't know which project this patch is for (you might want to run
`git config format.subjectprefix "PATCH $(basename "$PWD")"` in the root
of each of your local clones), but it might already have a __printf()-style
macro [1][2][3][4] to avoid using #ifdef everywhere.

Cheers,
  Eric

[1] 
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/compiler-gcc.h#n119
[2] https://cgit.freedesktop.org/mesa/mesa/tree/src/util/macros.h#n128
[3] https://cgit.freedesktop.org/wayland/wayland/tree/src/wayland-util.h#n59
[4] https://cgit.freedesktop.org/wayland/libinput/tree/src/libinput.h#n36

>  
>  static void
>  draw_string(cairo_t *cr,
> -- 
> 2.10.0
_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to