circular deps

Jarrett Billingsley kb3ctd2 at yahoo.com
Thu May 17 14:48:23 PDT 2007


"Scott" <bob at zone.com> wrote in message 
news:f2houk$2l1a$1 at digitalmars.com...
> Hi all,
>
> Whats the correct way to use imports to handle the following type of 
> circular dependency?
>
> //main.d --------------8<---------------
> import vec3, mat3, quat;
> int main() { return 0; }
>
> // mat3.d--------------8<---------------
> module mat3;
> import vec3, quat;
> struct Mat3 { Vec3[3] m; }
>
> // quat.d--------------8<---------------
> module quat;
> import vec3, mat3;
> struct Quat {}
>
> // vec3.d--------------8<---------------
> module vec3;
> import mat3, quat;
> struct Vec3 { }
>
>
> I get this back from the compiler....
>
> unixbox$ dmd main.d vec3.d mat3.d quat.d
> vec3.d(6): struct vec3.Vec3 no size yet for forward reference
> vec3.d(6): struct vec3.Vec3 no size yet for forward reference
> vec3.d(6): struct vec3.Vec3 no size yet for forward reference
> unixbox$

I would imagine that you have more code (so for example, vec3 really does 
depend on mat3 and quat).  As far as I'm concerned, this is a bug in the 
compiler that Walter has never been particularly intent on fixing.  I've 
always ended up just clumping any circularly-dependent modules into one 
file, even if it doesn't really make sense to.  Makes the compiler shut up. 





More information about the Digitalmars-d mailing list