Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 61b629d

Browse files
committed
libc: suppress libcxx's const-correct string overloads
libcxx checks for `defined(__CORRECT_ISO_CPP_STRING_H_PROTO)` before defining const-correct overloads for common string.h functions. C libraries should define this if they provide const-correct overloads. Bug: None Test: `clang -E` on a TU built with Bionic. No more const-correct Test: overloads from libcxx. Change-Id: I3d356c376f7845aadf1b5a56475863c9aea2eb4f
1 parent 3f8d890 commit 61b629d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

libc/include/string.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,10 @@ char* _Nonnull basename(const char* _Nonnull __path) __RENAME(__gnu_basename) __
185185

186186
/* Const-correct overloads. Placed after FORTIFY so we call those functions, if possible. */
187187
#if defined(__cplusplus)
188-
/*
189-
* Use two enable_ifs so these overloads don't conflict with + are preferred over libcxx's. This can
190-
* be reduced to 1 after libcxx recognizes that we have const-correct overloads.
191-
*/
192-
#define __prefer_this_overload __enable_if(true, "preferred overload") __enable_if(true, "")
188+
/* libcxx tries to provide these. Suppress that, since libcxx's impl doesn't respect FORTIFY. */
189+
#define __CORRECT_ISO_CPP_STRING_H_PROTO
190+
/* Used to make these preferable over regular <string.h> signatures for overload resolution. */
191+
#define __prefer_this_overload __enable_if(true, "")
193192
extern "C++" {
194193
inline __always_inline
195194
void* _Nullable __bionic_memchr(const void* _Nonnull const s __pass_object_size, int c, size_t n) {

0 commit comments

Comments
 (0)