typedef void t; int f(t); ?
Dave Hanson
drh at cs.Princeton.EDU
Sat Sep 15 06:03:11 AEST 1990
In article <1990Sep14.012909.1987 at twinsun.com> eggert at ata.twinsun.com (Paul Eggert) writes:
Is the following a conforming ANSI C program?
typedef void t;
int f(t);
int f(t) { return 0; }
3.5.4.3 (page 68 line 37) seems to say that line 2 is bad, because it mentions
the keyword `void' without talking about types. But 3.7.1 (page 83 line 6)
seems to say that line 3 is OK, because it talks about the void type. Surely
lines 2 and 3 are both OK, or both bad.
yes, this is a conforming program. the typedef simply equates t to void.
While we're on the subject, what about qualified voids?
int g(volatile void) { return 0; }
typedef volatile void c;
int g(c);
no, this program is in violation of the constraints of 3.7.1, which
stipulate that the single parameter must be either type void with
no identifier or a type other than void with an identifier.
More information about the Comp.std.c
mailing list