Inheritance in C.
This program, similarly to the standard preprocessor, can take a file and produce valid C syntax, providing inheritance features.
- Clone this repo
- Compile and view help:
$ make
$ ./cest -h
See examples for more info.
Currently only a single parent is supported. Support for multiple parents is planned.
Declare struct child
to inherit from struct Base
:
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_<typename>
, where <typename>
can be struct_<structname>
or the typedef'd name. S
may be appended for the pointer version.
Since this tool is not part of the regular C-toolchain, it needs to be called separately. Using a build tool like GNU Make or CMake, the following approach can be used:
- Instruct build tool to transform
.h.in
files and place them in build folder as.h
- Setup up build folder for includes, or directly include from there