-
-
Save abissell/443f75ec80f73163f2f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "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