typedef vs #define

Rick Schaut schaut at cat9.cs.wisc.edu
Tue Feb 27 16:36:48 AEST 1990


In article <1990Feb24.234433.14252 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
| 
| The #define is handled by the preprocessor, while the typedef is handled
| by the compiler proper.  (Actually, a less implementation-dependent way
| of stating this is that the #define is handled in ANSI C translation
| phase 4 while typedef is handled in phase 7.)  In this particular case,
| it will make little difference.  However, consider:
| 
| 	typedef int (*intfp)();
| 	intfp ptrarray[10];

Good example, but for those who aren't too adept at parsing C type
declarations perhaps the following is a bit more clear:

	typedef int (*ptr_to_int_function)();
	ptr_to_int_function funct_ptr_array[NUMFUNCTS];
--
Rick (schaut at garfield.cs.wisc.edu)

"I'm a theory geek; we use Turing machines!"--Gary Lewandowski



More information about the Comp.lang.c mailing list