Skip to content

Instantly share code, notes, and snippets.

@kienvo
Last active March 30, 2022 05:41
Show Gist options
  • Save kienvo/41a7ac2947ba23345c9501eacfc46000 to your computer and use it in GitHub Desktop.
Save kienvo/41a7ac2947ba23345c9501eacfc46000 to your computer and use it in GitHub Desktop.
Objective in C with MACRO
struct some_struct {int some; char value;};

#define SOME_STRUCT_INIT(name) 			\
	struct some_struct *name = malloc(sizeof(struct some_struct));\
	*name = (struct __##name){.some = 5, .value = 'a'}; // compound literal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment