| amogus.c | ||
| amogus.h | ||
| amogus.hh | ||
| base.h | ||
| build.sh | ||
| cxx-types.h | ||
| derived.cpp | ||
| main.c | ||
| main.cpp | ||
| README.md | ||
Simple C++ and C demo toying with the inner workings of the Itanium C++ ABI in regards to virtual classes and inheritance of such.
What's here:
Baseclass with one virtual functionwho(prints a message) and a virtual destructorDerived_Clangsubclass ofBase, compiled using ClangDerived_GCCsubclass ofBase, compiled using GCCDerived_Amogussubclass ofBase, written in C with an additional non-virtualventmethod- A heap-allocating "constructor" function for each Derived class
- Entry point (
main.cpp, compiled asbin/main). Calls each "constructor" to obtain the derived classes, then invokes theirwhofunctions, casts one of the allocated objects into an Amogus (checking the type at runtime), then makes it vent. - Same entry point, but rewritten in C (
main.c, compiled asbin/cmain).
The demo shows interoperability between the GCC and Clang C++ compilers, as well as a way to make use of a C++ ABI without writing C++ code.
To run the demo, first install GCC and Clang, then run ./build.sh, after which
executable files bin/main and bin/cmain become available.