https://github.com/xyproto/gcstr
Safe garbage collected strings for C, inspired by Go
https://github.com/xyproto/gcstr
c c11 go strings
Last synced: about 1 year ago
JSON representation
Safe garbage collected strings for C, inspired by Go
- Host: GitHub
- URL: https://github.com/xyproto/gcstr
- Owner: xyproto
- License: bsd-3-clause
- Created: 2021-05-30T17:16:29.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-11-03T22:44:48.000Z (over 4 years ago)
- Last Synced: 2025-03-29T03:04:00.584Z (over 1 year ago)
- Topics: c, c11, go, strings
- Language: C
- Homepage:
- Size: 53.7 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gcstr
Safe garbage collected strings for C, inspired by Go.
## Requirements
* A C compiler that supports C11, ie. `gcc` or `clang`.
* The garbage collection library [gc](http://www.hboehm.info/gc/) (available as the `gc` package in many Linux distros).
* `make` and `pkg-config`.
## Guidelines/limitations/ideas
* `-1` should never be returned to indicate a problem or that something is not found. Return a struct instead.
* `String*` should be supported by every function that can take a string.
* The `Error*` type can be `nil` to indicate no error. Otherwise, it should contain info about the error.
* In lack of generics, use function signatures that contains the types, like `const char* ErrorToCharPtr(Error* err);`. It's verbose, but clear.
* Make things correct first, then fast later.
* All functions may panic if memory can not be allocated.
* If functions may panic for other reasons, the function name must be prefixed with **Must**.
* Error messages should start with a lowercase letter and not end with punctuation.
* The API is stable for each major version number.
## Make
### Build
make
### Install
sudo make install
## [`CXX`](https://github.com/xyproto/cxx)
### Build and run tests
cxx run
## CMake and Ninja
### Build
cmake -B build -G Ninja -D CMAKE_INSTALL_PREFIX=/usr
ninja -C build
### Install
sudo ninja -C build install
## General info
* Version: 4.0.0
* License: BSD
* Author: Alexander F. Rødseth <xyproto@archlinux.org>