Why have xxx_t typedef names (was Re: Is typedef char BUFFER[20] legal?)

Karl Heuer karl at ima.isc.com
Thu Feb 14 15:01:36 AEST 1991


In article <3377 at unisoft.UUCP> greywolf at unisoft.UUCP (The Grey Wolf) writes:
>Is there/will there ever be a compile-time / cpp-time evaluation as to
>what types are defined?  For example:
>#if typed(stat_t) ...

Unlikely.  In the traditional implementation, the preprocessor has no way of
knowing anything about declared types.

>This would eliminate the need for putting that stuff in .h files like
>#ifndef _STAT_H_

A simpler solution would be to make typedefs idempotent, like macros.  (Since
a conforming implementation must already handle nested-scope typedefs like
	typedef int foo;
	void f(void) { typedef int foo; }
I doubt that handling same-scope typedefs correctly would be any worse.)

Unfortunately, ANSI didn't define it that way, so the best you can do in a
portable header is to use a guard macro.

>Also, do typedefs ever make it into an object's/executable's nlist?

I believe some compilers will do this if debugging is enabled.

Karl W. Z. Heuer (karl at ima.isc.com or uunet!ima!karl), The Walking Lint



More information about the Comp.lang.c mailing list