mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH] guard isascii() macro when using C++
@ 2021-01-05  1:48 Érico Nogueira
  2021-01-05 10:54 ` Markus Wichmann
  0 siblings, 1 reply; 2+ messages in thread
From: Érico Nogueira @ 2021-01-05  1:48 UTC (permalink / raw)
  To: musl; +Cc: Érico Rolim

From: Érico Rolim <ericonr@disroot.org>

otherwise one can get compilation errors in C++ code that uses isascii
as an identifier

this was spotted while building fceux
---
 include/ctype.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/ctype.h b/include/ctype.h
index 7936536f..32bcef4d 100644
--- a/include/ctype.h
+++ b/include/ctype.h
@@ -64,7 +64,9 @@ int   isascii(int);
 int   toascii(int);
 #define _tolower(a) ((a)|0x20)
 #define _toupper(a) ((a)&0x5f)
+#ifndef __cplusplus
 #define isascii(a) (0 ? isascii(a) : (unsigned)(a) < 128)
+#endif
 
 #endif
 
-- 
2.29.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [musl] [PATCH] guard isascii() macro when using C++
  2021-01-05  1:48 [musl] [PATCH] guard isascii() macro when using C++ Érico Nogueira
@ 2021-01-05 10:54 ` Markus Wichmann
  0 siblings, 0 replies; 2+ messages in thread
From: Markus Wichmann @ 2021-01-05 10:54 UTC (permalink / raw)
  To: musl

On Mon, Jan 04, 2021 at 10:48:34PM -0300, Érico Nogueira wrote:
> From: Érico Rolim <ericonr@disroot.org>
>
> otherwise one can get compilation errors in C++ code that uses isascii
> as an identifier
>

Well, this is a namespacing issue. The identifier in contention here is
only exposed if defines are set identifying the source file as POSIX
code. POSIX specifies the isascii macro, though it marks it as obsolete.
However, it means that no-one, C or C++, can use isascii as identifier
when including ctype.h if they declare POSIX compatibility. So one of
those three things has to go: Either the source files in question must
avoid including ctype.h, or they must avoid using the isascii
identifier, or they must avoid declaring POSIX compatibility. In all
cases, this is not a C vs. C++ issue, only a namespacing issue. And not
wrong in the library, but in the application.

Ciao,
Markus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-05 10:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-05  1:48 [musl] [PATCH] guard isascii() macro when using C++ Érico Nogueira
2021-01-05 10:54 ` Markus Wichmann

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).