From 4d7a261e7bd7412d7accaae4ec1c133e0b8d4bed Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 5 Jul 2023 16:23:58 +0200 Subject: [PATCH] Unbreak -Wformat warnings when gettext is used gettext replaces all *printf() functions on platforms that don't fully conform to the POSIX behaviour. Unfortunately, gettext fails to tag these replacement functions properly so that -Wformat can still do its thing. Resolve this by adding a redudant declaration of the relevant functions, with the attribute tagging in place. --- vncviewer/i18n.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/vncviewer/i18n.h b/vncviewer/i18n.h index 4a50b17c..0806d319 100644 --- a/vncviewer/i18n.h +++ b/vncviewer/i18n.h @@ -1,5 +1,5 @@ /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. - * Copyright 2011 Pierre Ossman for Cendio AB + * Copyright 2011-2023 Pierre Ossman for Cendio AB * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,6 +30,28 @@ pgettext_aux (const char *domain, #include "gettext.h" +/* gettext breaks -Wformat (upstream bug 64384) */ +#if defined(__GNUC__) && defined(printf) +extern int fprintf (FILE *, const char *, ...) + __attribute__((__format__ (__printf__, 2, 3))); +extern int printf (const char *, ...) + __attribute__((__format__ (__printf__, 1, 2))); +extern int sprintf (char *, const char *, ...) + __attribute__((__format__ (__printf__, 2, 3))); +extern int snprintf (char *, size_t, const char *, ...) + __attribute__((__format__ (__printf__, 3, 4))); +extern int asprintf (char **, const char *, ...) + __attribute__((__format__ (__printf__, 2, 3))); +#endif +#if defined(__GNUC__) && defined(wprintf) +extern int fwprintf (FILE *, const wchar_t *, ...) + __attribute__((__format__ (__printf__, 2, 3))); +extern int wprintf (const wchar_t *, ...) + __attribute__((__format__ (__printf__, 1, 2))); +extern int swprintf (wchar_t *, size_t, const wchar_t *, ...) + __attribute__((__format__ (__printf__, 3, 4))); +#endif + #define _(String) gettext (String) #define p_(Context, String) pgettext (Context, String) #define N_(String) gettext_noop (String) -- 2.39.5