Frontend for C, concentrating on: generation from code; single-file analysis; modification; and emission (to C code).
Use-cases this is designed to support:
- Generate/update
free
callingint cleanup_StructName(struct StructName*)
functions, e.g.:struct Foo { struct Bar *bar;}; struct Bar { int a; };
will generate:int cleanup_Bar(struct Bar*);
&int cleanup_Foo(struct Foo*);
(which internally will callcleanup_Bar
)
- With
fmt
of JSON, INI, YAML, TOML, &etc.:- Generate/update parsers from
const char*
tostruct
:const int StructName_<fmt>_parse(struct StructName*, const char*)
function; - Generate/update emitters from
struct
tochar*
:const int StructName_<fmt>_emit(const struct StructName*, char*)
function;
- Generate/update parsers from
- Generate Google Cloud client library for C (with Google Cloud API Discovery Service as input);
- Generate arbitrary C client libraries (with OpenAPI as input);
- Generating
#pragma
for every function to expose them for calling from, e.g., assembly
This C compiler has a very unusual design, the macro and C language are treated as one. The foci are:
- location start/end of function,
struct
, and feature macros (e.g.,#ifdef JSON_EMIT
then#endif /* JSON_EMIT */
); struct
fields.
…which enable a number of use-cases to be simply developed, e.g., see the list above.
- Macros aren't evaluated, which means a simple
#define LBRACE {
will break cdd-c. - Like
m4
, CMake, and other tools; cdd-c must be run before your code is built.
Install: CMake ; C compiler toolchain ; git. Then:
$ git clone "https://github.com/offscale/vcpkg" -b "project0"
# Windows:
$ vcpkg\bootstrap-vcpkg.bat
# Non-Windows:
$ ./vcpkg/bootstrap-vcpkg.sh
# Both Windows and non-Windows:
$ git clone "https://github.com/SamuelMarks/cdd-c" && cd "cdd-c" # Or your fork of this repo
# Windows
$ cmake -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_TOOLCHAIN_FILE="..\vcpkg\scripts\buildsystems\vcpkg.cmake" -S . -B "build"
# Non-Windows
$ cmake -DCMAKE_BUILD_TYPE='Debug' -DCMAKE_TOOLCHAIN_FILE='../vcpkg/scripts/buildsystems/vcpkg.cmake' -S . -B 'build'
# Both Windows and non-Windows:
$ cmake --build "build"
# Test
$ cd "build" && ctest -C "Debug" --verbose
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
This repository uses clang-format
to maintain source code formatted in LLVM style.
Before committing for the first time, please install pre-commit
on your system and then
execute the following command to install pre-commit hooks:
{{{
pre-commit install
}}}