1From 848c37e08f93ea14fbc430d5e85517da8a6589ac Mon Sep 17 00:00:00 2001
2From: Andrew Hsieh <andrewhsieh@google.com>
3Date: Sun, 27 Apr 2014 22:22:32 -0700
4Subject: [PATCH 08/12] Remove gcc warning about redefinition of putchar with
5 different visibility
6
7In NDK bionic's stdio.h, putchar appears as both a function prototype and a macro
8(later in the same header).  Because it's defined as a macro, libc++ replaces
9it with a function but with *different* visibility.  GCC 4.x complains [-Wattributes]
10
11   include/stdio.h:236:5: warning: conflicts with previous declaration here [-Wattributes]
12   int  putchar(int);
13
14Undefine putchar to avoid redefinition, and putchar does exist in libc.so
15---
16 include/cstdio | 13 +++++++++++++
17 1 file changed, 13 insertions(+)
18
19diff --git a/include/cstdio b/include/cstdio
20index 7787fad..8f2a7b0 100644
21--- a/include/cstdio
22+++ b/include/cstdio
23@@ -126,6 +126,19 @@ inline _LIBCPP_INLINE_VISIBILITY int __libcpp_putc(int __c, FILE* __stream) {ret
24 inline _LIBCPP_INLINE_VISIBILITY int putc(int __c, FILE* __stream) {return __libcpp_putc(__c, __stream);}
25 #endif  // putc
26
27+#ifdef __ANDROID__
28+// In bionic's stdio.h, putchar appears as both a function prototype and a macro (later
29+// in the same header).  Because it's defined as a macro, the following code snippet replaces
30+// it with a function but with *different* visibility.  GCC 4.x complains [-Wattributes]
31+//
32+//   include/stdio.h:236:5: warning: conflicts with previous declaration here [-Wattributes]
33+//     int  putchar(int);
34+//
35+// Undefine putchar to avoid redefinition, and putchar does exist in libc.so
36+//
37+#undef putchar
38+#endif
39+
40 #ifdef putchar
41 inline _LIBCPP_INLINE_VISIBILITY int __libcpp_putchar(int __c) {return putchar(__c);}
42 #undef putchar
43--
441.9.1.423.g4596e3a
45
46