Small collection of utilities and libraries for C99 that aims to simplify some development tasks.
Robust launch arguments parsing & handling with verb support
Single & double linked lists with custom node support and QoL functions
Basic chained HashMaps
Various string utilities
Toggleable debugging output functions
Completely macro-able
char
↔wchar_t
supportSmall extras like UUID4, CRC32B & platform detection
Supports a wide variety of OS, CPU ISA & Compilers
Other features to come as needed or requested
- More HashMap types & hashing/UUID algorithms & more utilities
Requirements:
● CMake 3.13+
● Qt's Jom (ReactOS only, replaces nmake)
Supported OS:
Windows, Cygwin, Linux & ReactOS
Supported Compilers:
MSVC, CLang, GCC, MinGW & TinyCC
Supported CPU architectures:
x86, x64, ARM & ARM64
Check platforms.md for more info on the platform detector.
Check definitions.md for a complete listing of the configuration definitions.
Firstly, insert the following lines into your CMakeLists.txt
:
# Including the `FetchContent` directives.
include(FetchContent)
# Configuring the library. (Optional)
set(NP_GOODIES_BUILD_BENCHMARKS OFF CACHE BOOL "" FORCE) # OFF by default.
set(NP_GOODIES_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # OFF by default.
set(NP_GOODIES_BUILD_TESTS OFF CACHE BOOL "" FORCE) # OFF by default.
# Downloading the library in the build folder.
FetchContent_Declare(
np_clang_goodies
GIT_REPOSITORY "https://github.com/aziascreations/C99-Utility-Libraries.git"
GIT_TAG "master"
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(np_clang_goodies)
# Moving the library into the build folder's root. (Optional)
set_target_properties(lib_np_clang_goodies PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/")
set_target_properties(lib_np_clang_goodies PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/")
set_target_properties(lib_np_clang_goodies PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/")
Finally, configure your targets like so:
# Configuring out target
add_executable(MyApp src/main.c) # Use your setup, only the target's name matters.
target_include_directories(MyApp PRIVATE ${PROJECT_INCLUDE}) # May be useless.
target_link_libraries(MyApp PRIVATE lib_np_clang_goodies)
add_dependencies(MyApp lib_np_clang_goodies) # Does nothing in my tests, but it can't hurt.
# Optional per-target config
target_compile_definitions(MyApp PUBLIC NP_DEBUG_LOGGING) # Enables debugging and optional error logging.
The Include
directive isn't supported yet.
The included project doesn't detect that it's being included properly like FetchContent
does.
The add_subdirectory
command works by isn't thoroughly tested yet.
Firstly, add this repository as a submodule in your project and checkout to a specific tag or commit:
git submodule add https://github.com/aziascreations/C99-Utility-Libraries.git libs/nibblepoker-c-goodies
git -C libs/nibblepoker-c-goodies checkout <hash|tag>
Afterward, add the following lines in your CMakeLists.txt:
add_subdirectory(libs/np_clang_goodies)
# This one may not be required, needs more testing.
file(GLOB_RECURSE src_nibblepoker_c_goodies CONFIGURE_DEPENDS "libs/nibblepoker-c-goodies/src/*.h" "libs/nibblepoker-c-goodies/src/*.c")
Finally, modify you targets to add ${src_nibblepoker_c_goodies}
like so:
add_executable(my_app src/main.c ${src_nibblepoker_c_goodies} ...)
In order to use this library in your projects via a manual import you need to do the following things:
Firstly, add this repository as a submodule in your project and checkout to a specific tag or commit:
git submodule add https://github.com/aziascreations/C99-Utility-Libraries.git libs/nibblepoker-c-goodies
git -C libs/nibblepoker-c-goodies checkout <hash|tag>
Afterward, add the following lines in your CMakeLists.txt:
file(
GLOB_RECURSE src_nibblepoker_c_goodies
CONFIGURE_DEPENDS "libs/nibblepoker-c-goodies/src/*.h" "libs/nibblepoker-c-goodies/src/*.c"
)
Finally, modify you targets to add ${src_nibblepoker_c_goodies}
like so:
add_executable(my_app src/main.c ${src_nibblepoker_c_goodies} ...)
Some examples that demonstrate how to use most of the functions this library provides can be found in the examples/ folder.
Alternatively, you can also check the aziascreations/C99-Win32-Wifi-Utility repository for a complete example in a "fully-fledged" Windows application.
- Basic usage with
char
&wchar_t
support- Define
NP_GOODIES_ARGUMENTS_USE_WCHAR
to supportwchar_t
instead ofchar
.
- Define
- Complete usage
- You may need to define
NP_DEBUG_LOGGING
to enable the special prints.
- You may need to define
- Basic operations
- Creating a list, adding, accessing & iteration over values and basic freeing call.
- Custom freeing operation
- Same as above while using structured data that needs to be freed in a specific way.
- Custom list nodes
- Same as above while using a custom superset of the standard list node in order to better suit some edge cases.
- Functions specific to double linked lists
- Testing functions that have a
dllist
-specific implementation.
- Testing functions that have a
- CRC32B hashing
- Basic example of hashing data with CRC32B.
- Basic Chained HashMap
- Basic HashMap usage with strings, CRC32B key hashing and full collision detection.
- UUID4 generation
- Rudimentary RNG setup & UUID4 generation.
- UUID4 generation with Win32API
- Safe RNG setup with Win32APIs & UUID4 generation.
TODO
You can consult the documentation at the following URL:
https://aziascreations.github.io/C99-Utility-Libraries/
It is automatically updated when a commit is pushed onto the master
branch.
If you want to build the documentation, you need to do the following things:
- Install Doxygen on your system.
- Clone the git submodules with
git submodule update --init --recursive
. - Run the make-doc.bat script.
- Go into
docs/html
and open theindex.html
file.
This project provides a couple of benchmarks in order to justify some of the design choices I made.
Please refer to the Benchmarks page for more information.
This project is dual-licensed under the following open-source licenses.
You can choose the one that best suits your needs:
-
MIT License
● Just include theLICENSE-MIT
file and be done with it while using an OSI license. -
CC0 1.0 Universal (CC0 1.0) (Public Domain)
● Do whatever you want with it.
● No credit, mentions or anything else is needed.
● Just have fun programming :)
Keep in mind, the doxygen-awesome-css submodule repository uses an
MIT license.
You can either not clone it or fork the project and remove it to be 100% safe if you use the CC0 1.0
license.
The documentation will still build without it, but it will have a "worse-looking" UI.