Skip to content

Small collection of utilities and libraries for C99 that aims to simplify some development tasks such as launch arguments parsing and double linked lists.

License

CC0-1.0, MIT licenses found

Licenses found

CC0-1.0
LICENSE-CC0
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

aziascreations/C99-Utility-Libraries

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NibblePoker's Clang Goodies

Small collection of utilities and libraries for C99 that aims to simplify some development tasks.

Features

  • 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 charwchar_t support
  • Small extras like UUID4, CRC32B & platform detection
  • Supports a wide variety of OS, CPU ISA & Compilers
  • Other features to come as needed or requested

Planned Features

  • More HashMap types & hashing/UUID algorithms & more utilities

Usage

Preamble

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.

CMake's FetchContent

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.

CMake's Include

The Include directive isn't supported yet.
The included project doesn't detect that it's being included properly like FetchContent does.

CMake's add_subdirectory command

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} ...)

CMake Manual Import

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} ...)

Examples

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.

Launch arguments

Debugging Utilities

  • Complete usage
    • You may need to define NP_DEBUG_LOGGING to enable the special prints.

Double Linked Lists

Hashing

HashMaps

  • Basic Chained HashMap
    • Basic HashMap usage with strings, CRC32B key hashing and full collision detection.

UUID

Text

TODO

Documentation

Viewing

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.

Building

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 the index.html file.

Benchmarks

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.

Licenses

This project is dual-licensed under the following open-source licenses.
You can choose the one that best suits your needs:

  1. MIT License
      ● Just include the LICENSE-MIT file and be done with it while using an OSI license.

  2. 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.

About

Small collection of utilities and libraries for C99 that aims to simplify some development tasks such as launch arguments parsing and double linked lists.

Topics

Resources

License

CC0-1.0, MIT licenses found

Licenses found

CC0-1.0
LICENSE-CC0
MIT
LICENSE-MIT

Stars

Watchers

Forks