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

Cookbook Chapter 2: Working with Enums. More...

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

Enumerations

enum  StatusCode { STATUS_OK = 0 , STATUS_WARN = 1 , STATUS_ERR = -1 }
 

Functions

static const char * status_to_string (StatusCode code)
 
int main ()
 

Detailed Description

Cookbook Chapter 2: Working with Enums.

This example shows how to handle C enum types. For the purpose of an FFI call, an enum behaves identically to its underlying integer type (which is int by default, unless specified otherwise).

The infix signature e:<type> is used to represent an enum. This makes the signature more descriptive, but for ABI purposes, it is treated exactly like its underlying <type>.

Enumeration Type Documentation

◆ StatusCode

enum StatusCode
Enumerator
STATUS_OK 
STATUS_WARN 
STATUS_ERR 

Function Documentation

◆ main()

int main ( void  )

◆ status_to_string()

static const char * status_to_string ( StatusCode  code)
static