template forward reference

Kirk McDonald kirklin.mcdonald at gmail.com
Tue Jul 31 13:46:44 PDT 2007


C. Dunn wrote:
> Witold Baryluk Wrote:
> 
>>Famous Bug #340 and especially #102.
> 
> 
> I do appreciate the response, but no, this is not the same bug.  In my case, if Foo is not a template, everything compiles and links.  It is somewhat related to #805 and #877, but I have submitted it as #1392.  (I read all 21 bugs related to #340.)
> 
> So it may be a related problem, but it is far more severe than just a restriction against "nested functions within a function and autotype declarations".  I'm doing something very simple -- simple enough that it compiles for non-templates.  It's really a problem with templates themselves.  And it works fine if it's all in the same file.  So it's a combination of 'import' and 'template'.
> 
> ...
> 
> I have found a work-around: If I compile the separate modules simultaneously, it works fine, even though it still produces separate .o files.  Curious.
>   dmd -c fooA.d fooFoo.d
> produces
>   fooA.o and fooFoo.o
> but
>   dmd -c fooFoo.d
> produces
>   fooA.d(9): template instance forward reference to template declaration Foo(T)
>   fooA.d(9): Error: Foo!(char) is used as a type
> 
> It seems like an awkward solution, but at least it works.

Goodness. That looks familiar. I used to have all kinds of problems with 
that in Pyd, but some DMD version or other cleared it all up. Which 
version of the compiler are you using?

-- 
Kirk McDonald
http://kirkmcdonald.blogspot.com
Pyd: Connecting D and Python
http://pyd.dsource.org



More information about the Digitalmars-d mailing list