Oddities in ANSI 3rd review

Guy Harris guy at gorodish.Sun.COM
Fri Aug 5 05:11:02 AEST 1988


> Well, a conforming implementation could certainly add members in the reserved
> namespace (leading underscore), and it could provide convenient access to
> them via a macro "#define tm_usec __tm_extended_usec" which is only defined
> if the user has enabled the extensions ("#include <extensions.h>" or
> whatever).

Or, alternatively, if your implementation has some way of distinguishing
"no-extensions" mode from "extensions" mode with some #ifdef at compile time,
you could do:

	struct tm {
		int	tm_sec;
		int	tm_min;
		int	tm_hour;
		int	tm_mday;
		int	tm_mon;
		int	tm_year;
		int	tm_wday;
		int	tm_yday;
		int	tm_isdst;
	#ifdef __EXTENSIONS__
		char	*tm_zone;
		long	tm_gmtoff;
	#else
		char	*__tm_filler_1;
		long	__tm_filler_2;
	#endif
	};

Unfortunately, there's no way to have unnamed fillers that aren't bit-fields,
so there's no way I can see of doing this without polluting your namespace with
ugly, although probably harmless "__tm_filler_N" names.  If you could do this,
I'd prefer it;

	struct tm {
		...
	#ifdef __EXTENSIONS__
		char	*tm_zone;
		long	tm_gmtoff;
	#else
		char	*;
		int;
	#endif
	};

anyone? :-)



More information about the Comp.lang.c mailing list