Giter Site home page Giter Site logo

sequpt / ctl Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 133 KB

A C11 library providing generic type-safe data structures compiling to actual structures and functions.

License: BSD Zero Clause License

Makefile 24.83% C 75.17%
abstract-data-types adt c c11 data-structures generic generic-programming template

ctl's Introduction

CTL - C Template Library

pipeline status license doxygen

A C11 library providing generic type-safe data structures compiling to actual structures and functions.

Table of Contents

Quick overview

#include <ctl/ctl.h>
#include <ctl/ctl_dyn_array.h>

#define CTL_DYN_ARRAY_TYPES_TYPES int, char
CTL_DECLARE(CTL_DYN_ARRAY, CTL_DYN_ARRAY_TYPES);
CTL_DEFINE(CTL_DYN_ARRAY, CTL_DYN_ARRAY_TYPES);

int main(int argc, char * argv[])
{
    CTL_DYN_ARRAY(int) * foo = ctl_DynArray_Create(foo);
    CTL_DYN_ARRAY(char) * bar = ctl_DynArray_Create(bar);
    ctl_DynArray_PushBack(foo, 3);
    ctl_DynArray_PushBack(foo, 7);
    ctl_DynArray_PushBack(bar, 'b');
    int a = ctl_DynArray_PopBack(foo); // a = 7
    char b = ctl_DynArray_PopBack(bar); // b = 'b'
    ctl_DynArray_Destroy(foo);
    ctl_DynArray_Destroy(bar);
    return 0;
}

Getting Started

Prerequisites

Although ctl is a header only library, a C11 compliant compiler is needed to use it in your project and to compile the tests.

Installation

Download or clone the repository:

git clone https://gitlab.com/callback/ctl.git

Optionally run the tests:

cd ctl
make all
make check

Install the headers globally to the standard default location /usr/local/include/ctl:

make install

Or install them to a different path /my/custom/path/include/ctl:

make install prefix=/my/custom/path

Add /usr/local/include/ctl or /my/custom/path/include/ctl to your include paths.

Documentation

Doxygen documentation is available here: https://callback.gitlab.io/ctl

Versioning

This project follows Semantic Versioning.

Changelog

See the CHANGELOG.md file.

Contributing

See the CONTRIBUTING.md file.

Interesting links

Here are a few interesting generic data structures libraries in C.

  • stb_ds.h: This is a single-header-file library that provides easy-to-use dynamic arrays and hash tables for C (also works in C++).
  • Klib: A standalone and lightweight C library.
  • Collections-C: A library of generic data structures including a list, array, hashtable, deque etc...

License

This project is licensed under the very permissive BSD Zero Clause License.

More information on the 0BSD license:

Thanks

ctl's People

Contributors

sequpt avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.