mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-07 21:50:08 +01:00
fd08fdb9df
FreeBSD 16.0-CURRENT's <string.h> now provides C23-style
qualifier-preserving wrappers for the string search functions. Besides
the prototype, `memrchr` (like `memchr`, `strchr`, `strstr`, `memmem`,
...) is also defined as a function-like macro built on `_Generic`:
#define memrchr(b, c, n) __qualsel((b), \
(const void *)(memrchr)((b), (c), (n)), (memrchr)((b), (c), (n)))
`common/memrchr.h` redeclares the function unconditionally. When
<string.h> has already been included, that declaration is expanded by
the macro and every translation unit fails with:
src/common/memrchr.h:11:7: error: expected identifier or '('
11 | void* memrchr(const void* s, int c, size_t n);
A libc that defines `memrchr` as a macro has necessarily declared the
function it wraps, so skip our declaration in that case. Nothing
changes on platforms where `memrchr` is not a macro, and the fallback
implementation is still selected by `check_function_exists`.
18 lines
374 B
C
18 lines
374 B
C
#pragma once
|
|
|
|
#include <stddef.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// `memrchr` is a GNU extension and may not be declared by system headers even when the symbol exists.
|
|
// Declare it unconditionally; the build system provides a fallback implementation when missing.
|
|
#ifndef memrchr
|
|
void* memrchr(const void* s, int c, size_t n);
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|