Skip to content

Instantly share code, notes, and snippets.

@abissell
Last active January 3, 2016 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abissell/443f75ec80f73163f2f8 to your computer and use it in GitHub Desktop.
Save abissell/443f75ec80f73163f2f8 to your computer and use it in GitHub Desktop.
// "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