F
Felix Kater
AFAIK there is no way in C to define one single function argument so
that two ore more explicitly declared types are allowed to pass
(so, either you pass the exact type or you need casts which I explicitly
do *not* want to consider here).
With the touch of a C enhancement in mind, I wonder, though, why
this shouldn't be allowed (it is *not* at least by my C compiler
gcc):
union u{
int i;
long l;
char* pc;
};
void f(u arg){
/* ... */
}
void main(int argc,char** argv){
i=99;
f(i); /* <-- INCOMPATIBLE TYPE */
}
Yes, of course, i is an int while union u is needed. On the other hand:
Wouldn't type checking be possible since all allowed types are defined
by the union u?
Thank You
Felix
that two ore more explicitly declared types are allowed to pass
(so, either you pass the exact type or you need casts which I explicitly
do *not* want to consider here).
With the touch of a C enhancement in mind, I wonder, though, why
this shouldn't be allowed (it is *not* at least by my C compiler
gcc):
union u{
int i;
long l;
char* pc;
};
void f(u arg){
/* ... */
}
void main(int argc,char** argv){
i=99;
f(i); /* <-- INCOMPATIBLE TYPE */
}
Yes, of course, i is an int while union u is needed. On the other hand:
Wouldn't type checking be possible since all allowed types are defined
by the union u?
Thank You
Felix