Is there a way to prevent mixing up arguments to parameters that are typedeffed or "defined" via alias/some other way?
Consider: https://godbolt.org/z/jrfPWePn1
typedef int type1;
typedef int type2;
#include <stdio.h>
void check(type1 a, type2 b){
printf("Howdy\n");
}
int main(){
type1 a = 4;
type2 b = 5;
check(b, a);
}
This works, but I don't want it to (ideal would be a compiler error) for the first argument to check at the calling location is of type type2 while the parameter is type1.
Is there any compiler settings which can issue warnings against such mixups? Or are there other idiomatic ways in which arguments of the same type, int, in this case are still checked whether they are of the right user defined types, such as type1 or type2 in the example above?
Posted Jan 14, 2026, 3:08 AM UTC
1118