Proposal: API for thread-safe time zone functions
Garrett Wollman
wollman at khavrinen.lcs.mit.edu
Fri Jun 8 15:02:05 UTC 2001
<<On Fri, 8 Jun 2001 11:02:09 +0100, "Clive D.W. Feather" <clive at demon.net> said:
> struct timezone; // Opaque structure
> typedef struct timezone timezone_t; // Opaque typedef
Not at all. That typedef is not opaque, it is entirely transparent,
and simply resolves to an incomplete structure. Consider the
following two-line compilation unit:
struct timezone *foo; // Compiles fine...
timezone_t foo; // Syntax error!
> Um, you mean that you want to be able to refer to the type without
> including the header ? Then just write both the above lines.
Then it is no longer opaque, and will result in errors when a user
program which actually uses the `timezone_t' interface includes the
header that declares it.
> You *are* using public and private headers, aren't you ? That is, users
> of your library include <timezone.h>
No, users of my library include <foo.h>. It defines some interfaces
which take a timezone parameter. It also defines some interfaces
which don't. The header for my library should stand alone; only
clients which need the timezone interfaces should include <timezone.h>
(or any other header). Clients of my library which do not need the
timezone interfaces should not suffer the namespace pollution of the
timezone header. This is the general case of the `FILE' botch.
-GAWollman
More information about the tz
mailing list