Skip to contentSkip to conversation

fix mingw cross compile failure due to printf redefinition in libintl.h

PATCH Superseded Andrey Borzenkov 2 participants 9 messages Dec 28, 2013 – Jan 25, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix mingw 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.

---
 include/grub/crypto.h   | 2 +-
 include/grub/emu/misc.h | 8 ++++----
 include/grub/err.h      | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)
include/grub/crypto.h +1 -1
index ec1b980..a24e89d 100644
@@ -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
include/grub/emu/misc.h +4 -4
index dde48c1..a588ba2 100644
@@ -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);
 
include/grub/err.h +1 -1
index 9896fcc..1590c68 100644
@@ -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 */
Signature · 1 line
tg: (093dec7..) u/mingw/attribute_printf (depends on: master)
#1 lore raw

PATCH v2 1/1 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

---
 grub-core/lib/libgcrypt/src/g10lib.h | 4 ++--
 include/grub/crypto.h                | 2 +-
 include/grub/emu/misc.h              | 8 ++++----
 include/grub/err.h                   | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)
grub-core/lib/libgcrypt/src/g10lib.h +2 -2
index 6bde20f..85a51be 100644
@@ -47,9 +47,9 @@
 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
 #define JNLIB_GCC_M_FUNCTION 1
 #define JNLIB_GCC_A_NR 	     __attribute__ ((noreturn))
-#define JNLIB_GCC_A_PRINTF( f, a )  __attribute__ ((format (printf,f,a)))
+#define JNLIB_GCC_A_PRINTF( f, a )  __attribute__ ((format (__printf__,f,a)))
 #define JNLIB_GCC_A_NR_PRINTF( f, a ) \
-			    __attribute__ ((noreturn, format (printf,f,a)))
+			    __attribute__ ((noreturn, format (__printf__,f,a)))
 #define GCC_ATTR_NORETURN  __attribute__ ((__noreturn__))
 #else
 #define JNLIB_GCC_A_NR
include/grub/crypto.h +1 -1
index ec1b980..a24e89d 100644
@@ -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
include/grub/emu/misc.h +4 -4
index dde48c1..a588ba2 100644
@@ -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);
 
include/grub/err.h +1 -1
index 9896fcc..1590c68 100644
@@ -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 */
Signature · 1 line
tg: (5ef569d..) u/mingw/attribute_printf (depends on: master)
#2 lore raw

Re: [PATCH v2] fix Mingw W64-32 cross compile failure due to printf redefinition in libintl.h

Quoted 6 lines · Andrey Borzenkov

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=]

Quoted 6 lines

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?

Quoted 69 lines
---
 grub-core/lib/libgcrypt/src/g10lib.h | 4 ++--
 include/grub/crypto.h                | 2 +-
 include/grub/emu/misc.h              | 8 ++++----
 include/grub/err.h                   | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)
grub-core/lib/libgcrypt/src/g10lib.h +2 -2
index 6bde20f..85a51be 100644
@@ -47,9 +47,9 @@
 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
 #define JNLIB_GCC_M_FUNCTION 1
 #define JNLIB_GCC_A_NR 	     __attribute__ ((noreturn))
-#define JNLIB_GCC_A_PRINTF( f, a )  __attribute__ ((format (printf,f,a)))
+#define JNLIB_GCC_A_PRINTF( f, a )  __attribute__ ((format (__printf__,f,a)))
 #define JNLIB_GCC_A_NR_PRINTF( f, a ) \
-			    __attribute__ ((noreturn, format (printf,f,a)))
+			    __attribute__ ((noreturn, format (__printf__,f,a)))
 #define GCC_ATTR_NORETURN  __attribute__ ((__noreturn__))
 #else
 #define JNLIB_GCC_A_NR
include/grub/crypto.h +1 -1
index ec1b980..a24e89d 100644
@@ -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
include/grub/emu/misc.h +4 -4
index dde48c1..a588ba2 100644
@@ -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);
 
include/grub/err.h +1 -1
index 9896fcc..1590c68 100644
@@ -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 */
#3 lore raw

Re: [PATCH v2] fix Mingw W64-32 cross compile failure due to printf redefinition in libintl.h

В Sat, 18 Jan 2014 17:24:53 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 7 lines · Andrey Borzenkov
Quoted 6 lines

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=]

Quoted 7 lines
Quoted 6 lines

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 <[email protected]>
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(-)
include/grub/crypto.h +1 -1
index ec1b980..a24e89d 100644
@@ -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
include/grub/emu/misc.h +4 -4
index dde48c1..a588ba2 100644
@@ -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);
 
include/grub/err.h +1 -1
index 9896fcc..1590c68 100644
@@ -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 */
util/import_gcry.py +6 -0
index 63ebb90..a3a903e 100644
@@ -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 ()
Signature · 1 line
tg: (e0a8509..) u/mingw/attribute_printf (depends on: master)
#4 lore raw

Re: [PATCH v2] fix Mingw W64-32 cross compile failure due to printf redefinition in libintl.h

Quoted 1 line · Andrey Borzenkov

+ fw.write (f.read ().replace ("(printf,f,a)", "(__printf__,f,a)").replace ("(printf,f,a)", "(__printf__,f,a)"))

Why replace twice?

#5 lore raw

Re: [PATCH v2] fix Mingw W64-32 cross compile failure due to printf redefinition in libintl.h

В Sat, 18 Jan 2014 20:07:31 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 4 lines · Andrey Borzenkov
Quoted 1 line

+ fw.write (f.read ().replace ("(printf,f,a)", "(__printf__,f,a)").replace ("(printf,f,a)", "(__printf__,f,a)"))

Why replace twice?

Somehow I though they had different number of arguments. Do not know why. Sorry.

#6 lore raw

Re: [PATCH v2] fix Mingw W64-32 cross compile failure due to printf redefinition in libintl.h

Quoted 11 lines · Andrey Borzenkov

В Sat, 18 Jan 2014 20:07:31 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 4 lines · Andrey Borzenkov
Quoted 1 line

+ fw.write (f.read ().replace ("(printf,f,a)", "(__printf__,f,a)").replace ("(printf,f,a)", "(__printf__,f,a)"))

Why replace twice?

Somehow I though they had different number of arguments. Do not know why. Sorry.

Can you send fixed patch for me to have a look, and, probably, approve.

Quoted 7 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#7 lore raw

Re: [PATCH v2] fix Mingw W64-32 cross compile failure due to printf redefinition in libintl.h

В Fri, 24 Jan 2014 21:34:17 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 5 lines · Andrey Borzenkov
Quoted 4 lines

В Sat, 18 Jan 2014 20:07:31 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 1 line · Andrey Borzenkov
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

+ fw.write (f.read ().replace ("(printf,f,a)", "(__printf__,f,a)").replace ("(printf,f,a)", "(__printf__,f,a)"))

Why replace twice?

Somehow I though they had different number of arguments. Do not know why. Sorry.

Can you send fixed patch for me to have a look, and, probably, approve.

From: Andrey Borzenkov <[email protected]>
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(-)
include/grub/crypto.h +1 -1
index ec1b980..a24e89d 100644
@@ -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
include/grub/emu/misc.h +4 -4
index dde48c1..a588ba2 100644
@@ -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);
 
include/grub/err.h +1 -1
index 9896fcc..1590c68 100644
@@ -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 */
util/import_gcry.py +6 -0
index 63ebb90..2b3322d 100644
@@ -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)"))
+        f.close ()
+        fw.close ()
+        continue
+
     fw.write (f.read ())
     f.close ()
     fw.close ()
Signature · 1 line
tg: (61c8482..) u/mingw/attribute_printf (depends on: master)
#8 lore raw

Re: [PATCH v2] fix Mingw W64-32 cross compile failure due to printf redefinition in libintl.h

Go ahead

Quoted 111 lines · Andrey Borzenkov

В Fri, 24 Jan 2014 21:34:17 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 5 lines · Andrey Borzenkov
Quoted 4 lines

В Sat, 18 Jan 2014 20:07:31 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 1 line · Andrey Borzenkov
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

+ fw.write (f.read ().replace ("(printf,f,a)", "(__printf__,f,a)").replace ("(printf,f,a)", "(__printf__,f,a)"))

Why replace twice?

Somehow I though they had different number of arguments. Do not know why. Sorry.

Can you send fixed patch for me to have a look, and, probably, approve.

From: Andrey Borzenkov <[email protected]>
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(-)
include/grub/crypto.h +1 -1
index ec1b980..a24e89d 100644
@@ -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
include/grub/emu/misc.h +4 -4
index dde48c1..a588ba2 100644
@@ -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);
 
include/grub/err.h +1 -1
index 9896fcc..1590c68 100644
@@ -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 */
util/import_gcry.py +6 -0
index 63ebb90..2b3322d 100644
@@ -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)"))
+        f.close ()
+        fw.close ()
+        continue
+
     fw.write (f.read ())
     f.close ()
     fw.close ()

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel