An open API service indexing awesome lists of open source software.

https://github.com/theoludwig/libcproject

C static library for learning purposes. Implement useful functions/data structures while being easier to use than `libc` (C standard library).
https://github.com/theoludwig/libcproject

c-programming-language gcc libc low-level

Last synced: 4 months ago
JSON representation

C static library for learning purposes. Implement useful functions/data structures while being easier to use than `libc` (C standard library).

Awesome Lists containing this project

README

          

libcproject


C static library easier to use than `libc` (C standard library).


Contributing
Licence MIT
Contributor Covenant


CI
Conventional Commits
semantic-release

## About

**libcproject** is a C static library for learning purposes. It tries to implement useful functions/data structures while being easier to use than `libc` (C standard library) as much as possible.

C is a low-level programming language and we often end up reinventing the wheel as the C standard library (`libc`) is quite small and in my humble opinion, not well designed.

**libcproject** solve this by providing common functions or data structures (`hash_map`, `array_list`, `linked_list`, `queue`, `stack`, etc.), we might need in our C projects.

[Online documentation](https://libcproject.vercel.app/).

## Prerequisites

- [GNU coreutils](https://www.gnu.org/software/coreutils/)
- [GNU binutils](https://www.gnu.org/software/binutils/)
- [GNU gcc](https://gcc.gnu.org/)
- [GNU make](https://www.gnu.org/software/make/)
- [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html)
- [Doxygen](https://www.doxygen.nl/)

For example on GNU/Linux Ubuntu:

```sh
# Install Build Tools
sudo apt install build-essential gcc make clang-format

# Install Documentation Tools
sudo apt install doxygen doxygen-gui doxygen-doc graphviz
```

## Usage

```sh
make # to compile
make run # to run main
make test # to run unit tests
make lint # to lint the code
make documentation # to generate the documentation
make clean # to clean up

nm ./build/libcproject.a # to see the symbols
```

Steps to create a new C project that uses `libcproject`:

### Step 1: Create a new project

```sh
mkdir my-project
cd my-project
```

### Step 2: Install and Compile `libcproject` in the project

```sh
# Clone the repository
git clone git@github.com:theoludwig/libcproject.git

# Go to libcproject directory
cd libcproject

# Compile the library
make
```

### Step 3: Create a new C file

```sh
cd ..
touch main.c
```

```cpp
#include
#include

#include "libcproject/libcproject.h"

int main() {
string_t string = "Hello, world!"; // `string_t` is a typedef from `libcproject`
printf("%s\n", string);
printf("string_length = %ld\n", string_get_length(string)); // `string_get_length` is a function from `libcproject`
return EXIT_SUCCESS;
}
```

### Step 4: Compile your project and link it with the library

```sh
gcc -o ./main ./main.c -L. -l:./libcproject/build/libcproject.a
```

## 💡 Contributing

Anyone can help to improve the project, submit a Feature Request, a bug report or even correct a simple spelling mistake.

The steps to contribute can be found in the [CONTRIBUTING.md](./CONTRIBUTING.md) file.

## 📄 License

[MIT](./LICENSE)