Re: [ooc-compiler] H20 bugs
Brought to you by:
mva
|
From: Stewart G. <sgr...@ii...> - 2006-02-16 04:46:38
|
Hi Frank,
> The glib library headers use an idiom that looks like this:
>
> typedef struct _GStaticMutex GStaticMutex;
> struct _GStaticMutex
> {
> struct _GMutex *runtime_mutex;
> union {
> char pad[24];
> double dummy_double;
> void *dummy_pointer;
> long dummy_long;
> } static_mutex;
> };
>
> As far as I can tell from the documentation, the leading underscore
> means the _GStaticMutex type is meant to be "opaque", presumably meaning
> its record fields should not be exported. However, this is simply a
> matter of convention and is not the real problem.
I think its done to ensure that the names used in structs and typedefs
don't collide. From memory, I think the C spec requires separate
name-spaces, but there may be compilers that don't do this. There
doesn't seem to be a consistent convention. In WIN32, structure tags are
prefixed with "tag", rather than "_".
> The code produced by TestH2O looks like this:
>
> TYPE
> _GStaticMutex_tag* = RECORD
> runtime_mutex* : POINTER TO _GMutex_tag;
> static_mutex* : RECORD [UNION]
> pad* : ARRAY 24 OF CHAR;
> dummy_double* : LONGREAL;
> dummy_pointer* : SYSTEM.PTR;
> dummy_long* : LONGINT;
> END;
> END;
> _GMutex_tag* = RECORD END;
> _GStaticMutex_tag* = RECORD END;
> GStaticMutex* = RECORD END;
>
> Naturally this doesn't compile.
Yes, that looks like H2O has got something wrong. In your code, struct
_GMutex is opaque but there is an error in the declaration of
GStaticMutex. When GStaticMutex is declared, _GStaticMutex is opaque but
that should not matter. It should have output just:
GStaticMutex* = _GStaticMutex_tag;
I'll take a look at what's wrong. Thanks too for your patch, which I'll
add to the CVS version.
Cheers,
Stewart
|