grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Borzenkov <arvidjaar@gmail.com>
To: grub-devel@gnu.org
Subject: Re: [PATCH v2] fix Mingw W64-32 cross compile failure due to printf redefinition in libintl.h
Date: Sat, 18 Jan 2014 23:02:08 +0400	[thread overview]
Message-ID: <20140118230208.044b1e22@opensuse.site> (raw)
In-Reply-To: <52DAAAD5.5000807@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 5003 bytes --]

В Sat, 18 Jan 2014 17:24:53 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <phcoder@gmail.com> пишет:

> On 18.01.2014 17:09, Andrey Borzenkov wrote:
> > In file included from util/misc.c:36:0:
> > ./include/grub/emu/misc.h:56:1: error: 'libintl_printf' is an unrecognized format function type [-Werror=format=]
> >  char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))) WARN_UNUSED_RESULT;
> >  ^
> > ./include/grub/emu/misc.h:58:1: error: 'libintl_printf' is an unrecognized format function type [-Werror=format=]
> > 
> > The reason is libintl.h which redefines printf as libintl_printf. The problem
> > is not present in native MinGW build which avoids redefinition.  Use
> > (format (__printf__) instead which is valid replacement in GCC.
> > 
> > v2: add grub-core/lib/libgcrypt/src/g10lib.h
> > 
> can we avoid modifying libgcrypt?

Well, we can do it during import?

From: Andrey Borzenkov <arvidjaar@gmail.com>
Subject: [PATCH v3] fix Mingw W64-32 cross compile failure due to printf redefinition in libintl.h

In file included from util/misc.c:36:0:
./include/grub/emu/misc.h:56:1: error: 'libintl_printf' is an unrecognized format function type [-Werror=format=]
 char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))) WARN_UNUSED_RESULT;
 ^
./include/grub/emu/misc.h:58:1: error: 'libintl_printf' is an unrecognized format function type [-Werror=format=]

The reason is libintl.h which redefines printf as libintl_printf. The problem
is not present in native MinGW build which avoids redefinition.  Use
(format (__printf__) instead which is valid replacement in GCC.

v2: add grub-core/lib/libgcrypt/src/g10lib.h
v3: modify g10lib.h during import

---
 include/grub/crypto.h   | 2 +-
 include/grub/emu/misc.h | 8 ++++----
 include/grub/err.h      | 2 +-
 util/import_gcry.py     | 6 ++++++
 4 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/include/grub/crypto.h b/include/grub/crypto.h
index ec1b980..a24e89d 100644
--- a/include/grub/crypto.h
+++ b/include/grub/crypto.h
@@ -408,7 +408,7 @@ void _gcry_assert_failed (const char *expr, const char *file, int line,
                           const char *func) __attribute__ ((noreturn));
 
 void _gcry_burn_stack (int bytes);
-void _gcry_log_error( const char *fmt, ... )  __attribute__ ((format (printf, 1, 2)));
+void _gcry_log_error( const char *fmt, ... )  __attribute__ ((format (__printf__, 1, 2)));
 
 
 #ifdef GRUB_UTIL
diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h
index dde48c1..a588ba2 100644
--- a/include/grub/emu/misc.h
+++ b/include/grub/emu/misc.h
@@ -53,11 +53,11 @@ grub_util_device_is_mapped (const char *dev);
 void * EXPORT_FUNC(xmalloc) (grub_size_t size) WARN_UNUSED_RESULT;
 void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) WARN_UNUSED_RESULT;
 char * EXPORT_FUNC(xstrdup) (const char *str) WARN_UNUSED_RESULT;
-char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))) WARN_UNUSED_RESULT;
+char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2))) WARN_UNUSED_RESULT;
 
-void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
-void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
-void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2), noreturn));
+void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2)));
+void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2)));
+void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2), noreturn));
 
 grub_uint64_t EXPORT_FUNC (grub_util_get_cpu_time_ms) (void);
 
diff --git a/include/grub/err.h b/include/grub/err.h
index 9896fcc..1590c68 100644
--- a/include/grub/err.h
+++ b/include/grub/err.h
@@ -91,6 +91,6 @@ int EXPORT_FUNC(grub_error_pop) (void);
 void EXPORT_FUNC(grub_print_error) (void);
 extern int EXPORT_VAR(grub_err_printed_errors);
 int grub_err_printf (const char *fmt, ...)
-     __attribute__ ((format (printf, 1, 2)));
+     __attribute__ ((format (__printf__, 1, 2)));
 
 #endif /* ! GRUB_ERR_HEADER */
diff --git a/util/import_gcry.py b/util/import_gcry.py
index 63ebb90..a3a903e 100644
--- a/util/import_gcry.py
+++ b/util/import_gcry.py
@@ -534,6 +534,12 @@ for src in sorted (os.listdir (os.path.join (indir, "src"))):
         fw.close ()
         continue
 
+    if src == "g10lib.h":
+        fw.write (f.read ().replace ("(printf,f,a)", "(__printf__,f,a)").replace ("(printf,f,a)", "(__printf__,f,a)"))
+        f.close ()
+        fw.close ()
+        continue
+
     fw.write (f.read ())
     f.close ()
     fw.close ()
-- 
tg: (e0a8509..) u/mingw/attribute_printf (depends on: master)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2014-01-18 19:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-28 18:00 [PATCH] fix mingw cross compile failure due to printf redefinition in libintl.h Andrey Borzenkov
2014-01-18 16:09 ` [PATCH v2] fix Mingw W64-32 " Andrey Borzenkov
2014-01-18 16:24   ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-01-18 19:02     ` Andrey Borzenkov [this message]
2014-01-18 19:07       ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-01-18 19:09         ` Andrey Borzenkov
2014-01-24 20:34           ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-01-25 15:51             ` Andrey Borzenkov
2014-01-25 17:05               ` Vladimir 'φ-coder/phcoder' Serbinenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140118230208.044b1e22@opensuse.site \
    --to=arvidjaar@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).