www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Forward Refrences

reply Trevor Parscal <Trevor_member pathlink.com> writes:
Hey all, I have been out of the "D Loop" so to speak for the past bit, as I took
some time from obsessive compulsive nonstop programming to move into a new house
and get married. Now things have settled down, and I am back to work on Terra...
Thanks to JRR FreeType is now working out with D and Terra can really start to
progress.

I updated my compiler to the latest, and now I am getting a compiler error about
forward refrences... So, anyhoo, I figured I would ask you all..

Has there been anything that has changed to do with forward refrences since last
time I compiled it in 0.128.

The refrence is to an ENUM like this...

enum RENDER
{
Visual,
Tactile,
Mask,
Masked
}

and the error just says..

"enum RENDER is forward refrenced"

and not where.. I check to see that all modules that use this enum include the
module this enum is in directly...

Any ideas?
Sep 26 2005
parent reply Derek Parnell <derek psych.ward> writes:
On Tue, 27 Sep 2005 05:57:29 +0000 (UTC), Trevor Parscal wrote:

 Hey all, I have been out of the "D Loop" so to speak for the past bit, as I
took
 some time from obsessive compulsive nonstop programming to move into a new
house
 and get married. Now things have settled down, and I am back to work on
Terra...
 Thanks to JRR FreeType is now working out with D and Terra can really start to
 progress.
 
 I updated my compiler to the latest, and now I am getting a compiler error
about
 forward refrences... So, anyhoo, I figured I would ask you all..
 
 Has there been anything that has changed to do with forward refrences since
last
 time I compiled it in 0.128.
 
 The refrence is to an ENUM like this...
 
 enum RENDER
 {
 Visual,
 Tactile,
 Mask,
 Masked
 }
 
 and the error just says..
 
 "enum RENDER is forward refrenced"
 
 and not where.. I check to see that all modules that use this enum include the
 module this enum is in directly...
 
 Any ideas?
Its the old story ... reduce it to the smallest example that exhibits this message and submit that. I've tried a number of things given what you have already told us and I can't get the message. -- Derek (skype: derek.j.parnell) Melbourne, Australia 27/09/2005 4:23:16 PM
Sep 26 2005
next sibling parent reply Trevor Parscal <Trevor_member pathlink.com> writes:
In article <89joqixrr5gf$.1el9h3pi6d9zn$.dlg 40tude.net>, Derek Parnell says...
On Tue, 27 Sep 2005 05:57:29 +0000 (UTC), Trevor Parscal wrote:

 Hey all, I have been out of the "D Loop" so to speak for the past bit, as I
took
 some time from obsessive compulsive nonstop programming to move into a new
house
 and get married. Now things have settled down, and I am back to work on
Terra...
 Thanks to JRR FreeType is now working out with D and Terra can really start to
 progress.
 
 I updated my compiler to the latest, and now I am getting a compiler error
about
 forward refrences... So, anyhoo, I figured I would ask you all..
 
 Has there been anything that has changed to do with forward refrences since
last
 time I compiled it in 0.128.
 
 The refrence is to an ENUM like this...
 
 enum RENDER
 {
 Visual,
 Tactile,
 Mask,
 Masked
 }
 
 and the error just says..
 
 "enum RENDER is forward refrenced"
 
 and not where.. I check to see that all modules that use this enum include the
 module this enum is in directly...
 
 Any ideas?
Its the old story ... reduce it to the smallest example that exhibits this message and submit that. I've tried a number of things given what you have already told us and I can't get the message. -- Derek (skype: derek.j.parnell) Melbourne, Australia 27/09/2005 4:23:16 PM
I narrowed it down to this... I only get the error when I use the enum as a function argument in the definition of the function... so.. file1.d /////////////// enum RENDER { Visual, Tactile } /////////////// file2.d /////////////// import file1; int test(RENDER _mode) // << this is where i get the problem { // do soemthing... } ///////////////// for now, I just cast my enums to uints and changed the functions to expect uints instead of the RENDER enum... But this is lame.. Why is this happeneing? It worked fine with 0.126 (what I think the last version I really had was) Any ideas? Thanks, Trevor Parscal
Sep 27 2005
parent Derek Parnell <derek psych.ward> writes:
On Tue, 27 Sep 2005 14:02:49 +0000 (UTC), Trevor Parscal wrote:

 In article <89joqixrr5gf$.1el9h3pi6d9zn$.dlg 40tude.net>, Derek Parnell says...
On Tue, 27 Sep 2005 05:57:29 +0000 (UTC), Trevor Parscal wrote:

 Hey all, I have been out of the "D Loop" so to speak for the past bit, as I
took
 some time from obsessive compulsive nonstop programming to move into a new
house
 and get married. Now things have settled down, and I am back to work on
Terra...
 Thanks to JRR FreeType is now working out with D and Terra can really start to
 progress.
 
 I updated my compiler to the latest, and now I am getting a compiler error
about
 forward refrences... So, anyhoo, I figured I would ask you all..
 
 Has there been anything that has changed to do with forward refrences since
last
 time I compiled it in 0.128.
 
 The refrence is to an ENUM like this...
 
 enum RENDER
 {
 Visual,
 Tactile,
 Mask,
 Masked
 }
 
 and the error just says..
 
 "enum RENDER is forward refrenced"
 
 and not where.. I check to see that all modules that use this enum include the
 module this enum is in directly...
 
 Any ideas?
Its the old story ... reduce it to the smallest example that exhibits this message and submit that. I've tried a number of things given what you have already told us and I can't get the message. -- Derek (skype: derek.j.parnell) Melbourne, Australia 27/09/2005 4:23:16 PM
I narrowed it down to this... I only get the error when I use the enum as a function argument in the definition of the function... so.. file1.d /////////////// enum RENDER { Visual, Tactile } /////////////// file2.d /////////////// import file1; int test(RENDER _mode) // << this is where i get the problem { // do soemthing... } ///////////////// for now, I just cast my enums to uints and changed the functions to expect uints instead of the RENDER enum... But this is lame.. Why is this happeneing? It worked fine with 0.126 (what I think the last version I really had was) Any ideas?
I'm using dmd v0.133 on Windows XP and I just tried your example and it works fine. I cannot reproduce your issue. <TEST> C:\TEMP>type test1.d enum RENDER { Visual, Tactile } C:\TEMP>type test2.d import test1; int test(RENDER _mode) // << this is where i get the problem { // do soemthing... } C:\TEMP>dmd -c test1 test2 C:\TEMP> </TEST> -- Derek Parnell Melbourne, Australia 28/09/2005 6:54:33 AM
Sep 27 2005
prev sibling parent reply Hasan Aljudy <hasan.aljudy gmail.com> writes:
Derek Parnell wrote:
 On Tue, 27 Sep 2005 05:57:29 +0000 (UTC), Trevor Parscal wrote:
 
 
Hey all, I have been out of the "D Loop" so to speak for the past bit, as I took
some time from obsessive compulsive nonstop programming to move into a new house
and get married. Now things have settled down, and I am back to work on Terra...
Thanks to JRR FreeType is now working out with D and Terra can really start to
progress.

I updated my compiler to the latest, and now I am getting a compiler error about
forward refrences... So, anyhoo, I figured I would ask you all..

Has there been anything that has changed to do with forward refrences since last
time I compiled it in 0.128.

The refrence is to an ENUM like this...

enum RENDER
{
Visual,
Tactile,
Mask,
Masked
}

and the error just says..

"enum RENDER is forward refrenced"

and not where.. I check to see that all modules that use this enum include the
module this enum is in directly...

Any ideas?
Its the old story ... reduce it to the smallest example that exhibits this message and submit that. I've tried a number of things given what you have already told us and I can't get the message.
Is it supposed to be a bug? I thought dmd just didn't support forward referencing of enums. ------------------<erf.d>----------------------------- void main() { EXAMPLE ex = EXAMPLE.t; dosomething(ex); } void dosomething(EXAMPLE a) { writef(a); } enum EXAMPLE { a,b,c,t,y,x,w,z } ----------------------------------------------------- When trying to compile, I get the messege enum EXAMPLE is forward referenced and the file doesn't get compiled. ------------------------------------------------------- D:\Documents and Settings\Aljudy\temp>dir Volume in drive D is Windows Volume Serial Number is C0DD-D039 Directory of D:\Documents and Settings\Aljudy\temp 09/27/2005 08:57 AM <DIR> . 09/27/2005 08:57 AM <DIR> .. 09/27/2005 08:57 AM 152 erf.d 1 File(s) 152 bytes 2 Dir(s) 554,704,896 bytes free D:\Documents and Settings\Aljudy\temp>dmd erf.d enum EXAMPLE is forward referenced D:\Documents and Settings\Aljudy\temp>dir Volume in drive D is Windows Volume Serial Number is C0DD-D039 Directory of D:\Documents and Settings\Aljudy\temp 09/27/2005 08:57 AM <DIR> . 09/27/2005 08:57 AM <DIR> .. 09/27/2005 08:57 AM 152 erf.d 1 File(s) 152 bytes 2 Dir(s) 554,704,896 bytes free D:\Documents and Settings\Aljudy\temp> -------------------------------------------------------
Sep 27 2005
next sibling parent Trevor Parscal <Trevor_member pathlink.com> writes:
In article <dhbmp3$2oq1$1 digitaldaemon.com>, Hasan Aljudy says...
Derek Parnell wrote:
 On Tue, 27 Sep 2005 05:57:29 +0000 (UTC), Trevor Parscal wrote:
 
 
Hey all, I have been out of the "D Loop" so to speak for the past bit, as I took
some time from obsessive compulsive nonstop programming to move into a new house
and get married. Now things have settled down, and I am back to work on Terra...
Thanks to JRR FreeType is now working out with D and Terra can really start to
progress.

I updated my compiler to the latest, and now I am getting a compiler error about
forward refrences... So, anyhoo, I figured I would ask you all..

Has there been anything that has changed to do with forward refrences since last
time I compiled it in 0.128.

The refrence is to an ENUM like this...

enum RENDER
{
Visual,
Tactile,
Mask,
Masked
}

and the error just says..

"enum RENDER is forward refrenced"

and not where.. I check to see that all modules that use this enum include the
module this enum is in directly...

Any ideas?
Its the old story ... reduce it to the smallest example that exhibits this message and submit that. I've tried a number of things given what you have already told us and I can't get the message.
Is it supposed to be a bug? I thought dmd just didn't support forward referencing of enums. ------------------<erf.d>----------------------------- void main() { EXAMPLE ex = EXAMPLE.t; dosomething(ex); } void dosomething(EXAMPLE a) { writef(a); } enum EXAMPLE { a,b,c,t,y,x,w,z } ----------------------------------------------------- When trying to compile, I get the messege enum EXAMPLE is forward referenced and the file doesn't get compiled. ------------------------------------------------------- D:\Documents and Settings\Aljudy\temp>dir Volume in drive D is Windows Volume Serial Number is C0DD-D039 Directory of D:\Documents and Settings\Aljudy\temp 09/27/2005 08:57 AM <DIR> . 09/27/2005 08:57 AM <DIR> .. 09/27/2005 08:57 AM 152 erf.d 1 File(s) 152 bytes 2 Dir(s) 554,704,896 bytes free D:\Documents and Settings\Aljudy\temp>dmd erf.d enum EXAMPLE is forward referenced D:\Documents and Settings\Aljudy\temp>dir Volume in drive D is Windows Volume Serial Number is C0DD-D039 Directory of D:\Documents and Settings\Aljudy\temp 09/27/2005 08:57 AM <DIR> . 09/27/2005 08:57 AM <DIR> .. 09/27/2005 08:57 AM 152 erf.d 1 File(s) 152 bytes 2 Dir(s) 554,704,896 bytes free D:\Documents and Settings\Aljudy\temp> -------------------------------------------------------
Well, I guess I'm not the only one... But, how can I make it not considder it to be forward refrenced? - Trevor Parscal
Sep 27 2005
prev sibling parent Chris Sauls <ibisbasenji gmail.com> writes:
Hasan Aljudy wrote:
 Is it supposed to be a bug? I thought dmd just didn't support forward 
 referencing of enums.
In the sense of your example, it is not supported, you're right. But in the original poster's case, the enum is defined in a seperate module which is then imported in the module giving the error. This usage does not constitute forward referencing. For myself, I'm confused by it. -- Chris Sauls
Sep 27 2005