cglm icon indicating copy to clipboard operation
cglm copied to clipboard

Proposal: Use C11 _Generic to struct API

Open quasar32 opened this issue 2 months ago • 1 comments

Use _Generic to create macros that allow for brevity and the creation of length generic code.

Example:

#define glms_add(a, b) _Generic((a), \
 	vec2s: glms_vec2_add, \
	vec3s: glms_vec3_add, \
	vec4s: glms_vec4_add \
)(a, b)

quasar32 avatar Nov 10 '25 21:11 quasar32

@quasar32 thanks for your feedback,

being verbose like glm_vec3_add(), glm_vec4_add() or vec3_add(), vec4_add()... makes intent explicit, no hidden magic... clear in all aspects.

lets get more feedback on this

recp avatar Nov 19 '25 21:11 recp