Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// "chkd_array_client.h"
#include "chkd_array_factory_head.h"
// Add client's new type named "strct" before defining generic functions
struct strct {
int a;
float b;
};
// List primitive types with == operator
#define CHKD_ARRAY_PRIMITIVE_TYPES(XX) \
XX(int, int, "chkd_array_int") \
XX(float, float, "chkd_array_float")
// List all types for which client needs chkd_array defined
#define CHKD_ARRAY_TYPES(XX) \
CHKD_ARRAY_PRIMITIVE_TYPES(XX) \
XX(struct strct, struct_strct, "chkd_array_struct_strct")
// Create generic function names for chkd_array * functions
#define GENERIC_ARRAY_PTR_FN_DEFINE(CHKD_ARRAY_PTR, FN_NAME) \
_Generic((CHKD_ARRAY_PTR), \
struct chkd_array_int *: (chkd_array_int ## _ ## FN_NAME), \
struct chkd_array_float *: (chkd_array_float ## _ ## FN_NAME), \
struct chkd_array_struct_strct *: (chkd_array_struct_strct ## _ ## FN_NAME))
// Declare and define the generic val ptr and chkd_array ptr functions
#include "chkd_array_factory_defs.h"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.