[comp.std.c] typedef void t; int f

eggert@ata.twinsun.com (Paul Eggert) (09/14/90)

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.


While we're on the subject, what about qualified voids?

	int g(volatile void) { return 0; }
	typedef volatile void c;
	int g(c);

drh@cs.Princeton.EDU (Dave Hanson) (09/15/90)

In article <1990Sep14.012909.1987@twinsun.com> eggert@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.