What I mean is normally solved with using an enum
:
enum AddrFam { af_unspec, af_inet, af_inet6 };
void myfunc(AddrFam) {} // e.g. for lower case constants
void myfunc(int) {} // e.g. for upper case constants
int main() {
myfunc(af_unix);
return 0;
}
This results with the compiler error:
error: ‘af_unix’ was not declared in this scope
15 | myfunc(af_unix);
| ^~~~~~~
That is as expected. But how can I achieve the same with the predefined upper case constants? I cannot use the already predefined constants AF_UNSPEC, AF_INET, AF_INET6
in an enum
so
myfunc(AF_UNIX);
compiles without error.