infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
Ch05_CppMangledNames.c File Reference

Cookbook Chapter 5: Calling C++ Mangled Names. More...

#include <infix/infix.h>
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for Ch05_CppMangledNames.c:

Functions

int main ()
 

Variables

const char * LIB_NAME = "./libmyclass.so"
 

Detailed Description

Cookbook Chapter 5: Calling C++ Mangled Names.

This example demonstrates the advanced and fragile technique of manually replicating the C++ new and delete operators from C.

This is a two-step process:

  1. new: First, allocate raw memory (malloc), then call the constructor on that memory with its mangled name.
  2. delete: First, call the destructor with its mangled name, then free the raw memory (free).
Warning
This technique is shown for educational purposes. It is not robust because it depends on compiler-specific name mangling. The strongly recommended best practice is to use extern "C" factory functions (create_object/destroy_object) to hide this complexity.

Function Documentation

◆ main()

int main ( void  )

Variable Documentation

◆ LIB_NAME

const char* LIB_NAME = "./libmyclass.so"