mailing list of musl libc
 help / color / mirror / 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

mailing list of musl libc

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/musl

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 musl musl/ http://inbox.vuxu.org/musl \
		musl@inbox.vuxu.org
	public-inbox-index musl

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.musl


code repositories for the project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git