https://github.com/cpiber/cest
Simple inheritance in C
https://github.com/cpiber/cest
Last synced: over 1 year ago
JSON representation
Simple inheritance in C
- Host: GitHub
- URL: https://github.com/cpiber/cest
- Owner: cpiber
- License: mit
- Created: 2022-03-03T11:21:55.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-04-26T16:52:33.000Z (about 4 years ago)
- Last Synced: 2025-01-15T23:24:56.119Z (over 1 year ago)
- Language: C
- Size: 41 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cest
Inheritance in C.
This program, similarly to the standard preprocessor, can take a file and produce valid C syntax, providing inheritance features.
## Getting started
1. Clone this repo
1. Compile and view help:
```console
$ make
$ ./cest -h
```
See [examples](./examples) for more info.
## Syntax
Currently only a single parent is supported. Support for multiple parents is planned.
Declare `struct child` to inherit from `struct Base`:
```c
struct Child (struct Base) {
// child members
};
```
Currently using any struct present in the current file and its includes is possible, as well as names from direct `typedef`s (i.e. `typedef struct ... name;`). Support for separate `typedef`s is planned.
The special name `CEST_MACROS_HERE` is used to denote the place where the casting-macros should be placed.
The macros allow type-safe casting of child-structs to their parent structs. They are of the form `CEST_AS_`, where `` can be `struct_` or the typedef'd name. `S` may be appended for the pointer version.
## Integrating into the build
Since this tool is not part of the regular C-toolchain, it needs to be called separately. Using a build tool like [GNU Make](https://www.gnu.org/software/make/) or [CMake](https://cmake.org/), the following approach can be used:
1. Instruct build tool to transform `.h.in` files and place them in build folder as `.h`
1. Setup up build folder for includes, or directly include from there