Compiler error with static vars/functions

Oliver Plow saxo123 at gmx.de
Thu Feb 9 13:42:17 PST 2012


Thanks for the answer. This means that all classes belonging to the same module must be in the same *.d file? I mean not one *.d file per class as in most languages?

Regards, Oliver


-------- Original-Nachricht --------
> Datum: Thu, 09 Feb 2012 14:18:07 -0500
> Von: "Jonathan M Davis" <jmdavisProg at gmx.com>
> An: "digitalmars.D.learn" <digitalmars-d-learn at puremagic.com>
> Betreff: Re: Compiler error with static vars/functions

> On Thursday, February 09, 2012 14:57:08 Oliver Plow wrote:
> > Hello,
> > 
> > I'm fighting with a strange compiler error. This here compiles and runs
> > fine:
> > 
> [snip]
> >
> > This is a bit strange for me. Apparently, must be some kind of import
> > problem importing Foo. But I don't see how ...
> 
> It's because you named both your module and type Foo. So, when you import
> Foo, 
> Foo.z is a module-level symbol in Foo (which does not exist). You'd need
> to do 
> Foo.Foo.z. If your module were named something completele different (e.g. 
> xyzzy), then Foo.z would then be referring to your class Foo's z variable,
> and 
> it would work.
> 
> Normally, it's considered good practice to give modules names which are
> all 
> lowercase (particularly since some OSes aren't case-sensitive for file
> operations). Renaming your module to foo should fix your problem.
> 
> - Jonathan M Davis

-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de


More information about the Digitalmars-d-learn mailing list