• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From 3754d92809b7067a98e38a19ea4e10b36ad52bc7 Mon Sep 17 00:00:00 2001
2From: Carl Norum <carl@norum.ca>
3Date: Sun, 27 Apr 2014 22:21:24 -0700
4Subject: [PATCH 07/12] Fix libc++ compiler error when calling std::feof()
5
6The following functions are "macro" in bionic's stdio.h and also
7defined in cstdio's std::  getchar, putchar, clearerr, feof, ferror
8
9Undef them and re-define as inlined functions otherwise use of
10std::feof, for example, break compilation.
11
12See b.android.com/66668 and b.android.com/36496
13---
14 include/cstdio | 30 ++++++++++++++++++++++++++++++
15 1 file changed, 30 insertions(+)
16
17diff --git a/include/cstdio b/include/cstdio
18index ce3af4d..7787fad 100644
19--- a/include/cstdio
20+++ b/include/cstdio
21@@ -114,12 +114,42 @@ inline _LIBCPP_INLINE_VISIBILITY int __libcpp_getc(FILE* __stream) {return getc(
22 inline _LIBCPP_INLINE_VISIBILITY int getc(FILE* __stream) {return __libcpp_getc(__stream);}
23 #endif  // getc
24
25+#ifdef getchar
26+inline _LIBCPP_INLINE_VISIBILITY int __libcpp_getchar(void) {return getchar();}
27+#undef getchar
28+inline _LIBCPP_INLINE_VISIBILITY int getchar(void) {return __libcpp_getchar();}
29+#endif  // getchar
30+
31 #ifdef putc
32 inline _LIBCPP_INLINE_VISIBILITY int __libcpp_putc(int __c, FILE* __stream) {return putc(__c, __stream);}
33 #undef putc
34 inline _LIBCPP_INLINE_VISIBILITY int putc(int __c, FILE* __stream) {return __libcpp_putc(__c, __stream);}
35 #endif  // putc
36
37+#ifdef putchar
38+inline _LIBCPP_INLINE_VISIBILITY int __libcpp_putchar(int __c) {return putchar(__c);}
39+#undef putchar
40+inline _LIBCPP_INLINE_VISIBILITY int putchar(int __c) {return __libcpp_putchar(__c);}
41+#endif  // putchar
42+
43+#ifdef clearerr
44+inline _LIBCPP_INLINE_VISIBILITY void __libcpp_clearerr(FILE* __stream) {return clearerr(__stream);}
45+#undef clearerr
46+inline _LIBCPP_INLINE_VISIBILITY void clearerr(FILE* __stream) {return __libcpp_clearerr(__stream);}
47+#endif  // clearerr
48+
49+#ifdef feof
50+inline _LIBCPP_INLINE_VISIBILITY int __libcpp_feof(FILE* __stream) {return feof(__stream);}
51+#undef feof
52+inline _LIBCPP_INLINE_VISIBILITY int feof(FILE* __stream) {return __libcpp_feof(__stream);}
53+#endif  // feof
54+
55+#ifdef ferror
56+inline _LIBCPP_INLINE_VISIBILITY int __libcpp_ferror(FILE* __stream) {return ferror(__stream);}
57+#undef ferror
58+inline _LIBCPP_INLINE_VISIBILITY int ferror(FILE* __stream) {return __libcpp_ferror(__stream);}
59+#endif  // ferror
60+
61 _LIBCPP_BEGIN_NAMESPACE_STD
62
63 using ::FILE;
64--
651.9.1.423.g4596e3a
66
67