Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 0 additions & 4 deletions cstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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'};
Expand Down
14 changes: 1 addition & 13 deletions cstr.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -28,10 +28,6 @@
#include <stddef.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/* ==========================================================================
* 1. Configuration & Feature Flags (Section 17)
* ========================================================================== */
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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 */
2 changes: 1 addition & 1 deletion docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Loading