Re: Forward references

2021-06-10 Thread Elmar via Digitalmars-d-learn
Hello there, I got a weird compilation error which was hard to debug (even for just a little program) and I thought, this is quite related to this thread. This is my error message: ``` ***search.d(42,1): Error: class ***.XXX has forward references ***box.d(21,32): Error: template instance ***

Re: Forward references

2018-02-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/25/18 6:53 PM, Jiyan wrote: On Sunday, 25 February 2018 at 22:20:13 UTC, Steven Schveighoffer wrote: On 2/25/18 4:25 PM, Jiyan wrote: [...] Looks like this was fixed in 2.064. What version of the compiler are you using? -Steve 2.077.0 It is really strange, it works now but there sti

Re: Forward references

2018-02-25 Thread Jiyan via Digitalmars-d-learn
On Sunday, 25 February 2018 at 22:20:13 UTC, Steven Schveighoffer wrote: On 2/25/18 4:25 PM, Jiyan wrote: [...] Looks like this was fixed in 2.064. What version of the compiler are you using? -Steve 2.077.0 It is really strange, it works now but there still seems to be some strangeness a

Re: Forward references

2018-02-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/25/18 4:25 PM, Jiyan wrote: Hi, is there any document or text describing forward references? It is kinda strange, i implemented a list structure which is kinda like this: struct list(T) { private: struct node { T val; node* next; node* prev; } node* head; node* last; size_t size;  ...

Re: Forward references

2018-02-25 Thread ketmar via Digitalmars-d-learn
works for me with 2.076.

Re: Forward references and more

2009-10-13 Thread Steven Schveighoffer
On Tue, 13 Oct 2009 07:30:11 -0400, bearophile wrote: Steven Schveighoffer: A static variable is essentially a scoped global variable. I think it will work if you make it static. I've used plenty of static variables that are instances of the struct they are declared in. It doesn't compi

Re: Forward references and more

2009-10-13 Thread bearophile
Steven Schveighoffer: > A static variable is essentially a scoped global variable. I think it > will work if you make it static. I've used plenty of static variables > that are instances of the struct they are declared in. It doesn't compile with static variables too, you just need few seco

Re: Forward references and more

2009-10-12 Thread Steven Schveighoffer
On Mon, 12 Oct 2009 15:38:07 -0400, bearophile wrote: Steven Schveighoffer: It looks strange what you are doing. A Foo can have a memory pool of a lot of Foo's? Do you mean to make the memory pool static? Right and yes. I think that might work.< It works if I use a global variable.

Re: Forward references and more

2009-10-12 Thread bearophile
Ary Borenszweig: > I can see MemoryPool!(Foo) sizeof doesn't depend at all of T.sizeof > because it just has a pointer. Well, a dynamic array of pointers, but the situation is the same. >But how do you suggest to fix the compiler to understand that?< I don't know. I don't know enough about co

Re: Forward references and more

2009-10-12 Thread Ary Borenszweig
Steven Schveighoffer wrote: On Mon, 12 Oct 2009 05:26:58 -0400, bearophile wrote: What's wrong with this code? struct MemoryPool(T) { alias T[100_000 / T.sizeof] Chunk; Chunk*[] chunks; } struct Foo { int x; MemoryPool!(Foo) pool; } void main() {} It prints "Error: struct pr

Re: Forward references and more

2009-10-12 Thread bearophile
Steven Schveighoffer: > It looks strange what you are doing. A Foo can have a memory pool of a > lot of Foo's? Do you mean to make the memory pool static? Right and yes. >I think that might work.< It works if I use a global variable. But I'd like to not used global variables when possible

Re: Forward references and more

2009-10-12 Thread Steven Schveighoffer
On Mon, 12 Oct 2009 05:26:58 -0400, bearophile wrote: What's wrong with this code? struct MemoryPool(T) { alias T[100_000 / T.sizeof] Chunk; Chunk*[] chunks; } struct Foo { int x; MemoryPool!(Foo) pool; } void main() {} It prints "Error: struct problem.Foo no size yet for fo

Re: Forward references and more

2009-10-12 Thread bearophile
> T.sizeof must be 8 in all cases. Ignore this line, please :-)