This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[PATCH] stdio.h: guard function macros with !__cplusplus
- From: Yaakov Selkowitz <yselkowi at redhat dot com>
- To: newlib at sourceware dot org
- Date: Tue, 13 Jun 2017 15:00:21 -0500
- Subject: [PATCH] stdio.h: guard function macros with !__cplusplus
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=yselkowi at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9FB4880F9F
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9FB4880F9F
While POSIX allows these functions to also be defined as macros in C, in
C++ this is not allowed, and prevents these names (particularly feof) from
being used in a custom namespace.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
---
newlib/libc/include/stdio.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h
index 097b0f665..1c32423d3 100644
--- a/newlib/libc/include/stdio.h
+++ b/newlib/libc/include/stdio.h
@@ -718,6 +718,7 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
#define __sfileno(p) ((p)->_file)
+#ifndef __cplusplus
#ifndef _REENT_SMALL
#define feof(p) __sfeof(p)
#define ferror(p) __sferror(p)
@@ -740,6 +741,7 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
#define putc(x, fp) __sputc_r(_REENT, x, fp)
#endif /* lint */
#endif /* __CYGWIN__ */
+#endif /* __cplusplus */
#if __MISC_VISIBLE
/* fast always-buffered version, true iff error */
--
2.12.3