diff --git a/README.md b/README.md index 4212a0d..9d41bfd 100755 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Benchmarks](https://github.com/ThirdLetterC/cstr/actions/workflows/benchmark.yml/badge.svg?branch=main)](https://github.com/ThirdLetterC/cstr/actions/workflows/benchmark.yml) [![Fuzz](https://github.com/ThirdLetterC/cstr/actions/workflows/fuzz.yml/badge.svg?branch=main)](https://github.com/ThirdLetterC/cstr/actions/workflows/fuzz.yml) -`cstr` is a self-contained string library for ISO C11, C17, C23, and C++ (through `extern "C"`). +`cstr` is a self-contained string library for ISO C11, C17, and C23. Copy [cstr.h](cstr.h) and [cstr.c](cstr.c) into your project to use it. The default build needs no external libraries or data files at runtime. diff --git a/cstr.c b/cstr.c index f7305a4..ee83e43 100644 --- a/cstr.c +++ b/cstr.c @@ -105,11 +105,7 @@ static inline bool cs_mul_overflow_sz(size_t a, size_t b, size_t *out) { #endif } -#if defined(__cplusplus) -#define CS_ALIGNOF(T) alignof(T) -#else #define CS_ALIGNOF(T) _Alignof(T) -#endif /* Internal static empty NUL sentinel so cs_c_str() is always non-NULL */ static const char cs_empty_cstr_sentinel[1] = {'\0'}; diff --git a/cstr.h b/cstr.h index d731856..b35d72c 100644 --- a/cstr.h +++ b/cstr.h @@ -1,5 +1,5 @@ /* ========================================================================== - * cstr.h — Self-Contained String & Unicode Library for ISO C11/C17/C23/C++ + * cstr.h — Self-Contained String & Unicode Library for ISO C11/C17/C23 * * SPDX-License-Identifier: MIT AND Unicode-3.0 * Copyright (c) 2026 Yehor Smoliakov @@ -28,10 +28,6 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif - /* ========================================================================== * 1. Configuration & Feature Flags (Section 17) * ========================================================================== */ @@ -167,11 +163,7 @@ typedef struct cs_builder { } cs_builder; /* Convenience view constructors */ -#ifdef __cplusplus -#define CS_LIT(literal) (cs_view{(literal), sizeof(literal) - 1U}) -#else #define CS_LIT(literal) ((cs_view){(literal), sizeof(literal) - 1U}) -#endif static inline cs_view cs_empty_view(void) { cs_view v = {NULL, 0}; @@ -1058,8 +1050,4 @@ bool cs_backend_supported(cs_backend backend); cs_status cs_set_forced_backend(cs_backend backend); const char *cs_backend_name(cs_backend backend); -#ifdef __cplusplus -} -#endif - #endif /* CSTR_H_INCLUDED */ diff --git a/docs/building.md b/docs/building.md index e9d8172..5dd5997 100644 --- a/docs/building.md +++ b/docs/building.md @@ -4,7 +4,7 @@ ## Add cstr to a project -Copy [cstr.h](../cstr.h) and [cstr.c](../cstr.c) into your project. Include `cstr.h` where you use the API, and compile `cstr.c` with your sources. C++ callers use the header's `extern "C"` declarations. +Copy [cstr.h](../cstr.h) and [cstr.c](../cstr.c) into your project. Include `cstr.h` where you use the API, and compile `cstr.c` with your C sources. The library supports ISO C11, C17, and C23. The commands below use C11 and GCC. Run them from the project root. They link the system math library with `-lm`, as the Makefile does.