libc
(C standard library).
https://libcproject.vercel.app/
.github | ||
doxygen-awesome-css@df83fbf22c | ||
lib | ||
test | ||
.clang-format | ||
.commitlintrc.json | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
.gitmodules | ||
.releaserc.json | ||
CODE_OF_CONDUCT.md | ||
CONTRIBUTING.md | ||
Doxyfile | ||
DoxygenLayout.xml | ||
libcproject.h | ||
LICENSE | ||
main.c | ||
Makefile | ||
README.md | ||
set_version.c | ||
version.h |
libcproject
C static library easier to use than `libc` (C standard library).
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 (dictionary
, linked_list
, queue
, stack
, etc.) we might need in our C projects.
Prerequisites
For example on GNU/Linux Ubuntu:
sudo apt-get install build-essential gcc make clang-format
sudo apt-get install doxygen doxygen-gui doxygen-doc graphviz
Usage
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: Install and Compile libcproject
# Clone the repository
git clone git@github.com:theoludwig/libcproject.git
# Go to libcproject directory
cd libcproject
# Compile the library
make
Step 2: Create a new project
mkdir my-project
cd my-project
Step 3: Install libcproject
in the project
mkdir libcproject
cp --recursive <path-to-libcproject> ./ # copy
# or
ln -s <path-to-libcproject> ./ # symbolic link
Step 4: Create a new C file
touch main.c
#include <stdio.h>
#include <stdlib.h>
#include "libcproject/libcproject.h"
int main() {
string string_value = "Hello, world!"; // `string` is a typedef from `libcproject`
printf("%s\n", string_value);
printf("string_length = %ld\n", string_get_length(string_value)); // `string_get_length` is a function from `libcproject`
return EXIT_SUCCESS;
}
Step 5: Compile your project and link it with the library
gcc -o ./main.exe ./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 file.