FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Forward References?

 
Post new topic   Reply to topic     Forum Index -> General
View previous topic :: View next topic  
Author Message
ndove



Joined: 12 Oct 2004
Posts: 6
Location: Las Vegas

PostPosted: Sun Oct 24, 2004 12:58 am    Post subject: Forward References? Reply with quote

I'm lost on this one, so I'll just get straight to the code:

Code:

// layout.d
struct Bounds
{
   int Bottom = 0;
   int Left   = 0;
   int Right  = 0;
   int Top    = 0;
}

struct Position
{
   int X = 0;
   int Y = 0;
}


Upon compilation, I get the errors:

layout.d(20): struct Bounds no size yet for forward reference
layout.d(20): struct Bounds no size yet for forward reference
layout.d(20): struct Bounds no size yet for forward reference
layout.d(28): struct Position no size yet for forward reference
layout.d(28): struct Position no size yet for forward reference
layout.d(28): struct Position no size yet for forward reference

Those line numbers are for the opening brace after the struct declaration ( { )

Any ideas?

EDIT:
I thought that I should include this:
Code:

class Something
{
   Bounds   bounds;
   Position position;
}

(you get the idea... hopefully...)
_________________
- Nick
- AIM: ndovelv
- Yahoo: ndovelv
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
larsivi
Site Admin


Joined: 27 Mar 2004
Posts: 453
Location: Trondheim, Norway

PostPosted: Sun Oct 24, 2004 1:24 am    Post subject: Reply with quote

I'm not sure if it is a bug in the compiler or not, but the following workaround usually works for me:

Wherever Something is declared, make sure it is below the structs referenced if in the same file. If in different files, make sure Something is declared below the import of the other file. Note that circular references in structs can be a pain.
Back to top
View user's profile Send private message
ndove



Joined: 12 Oct 2004
Posts: 6
Location: Las Vegas

PostPosted: Sun Oct 24, 2004 3:07 am    Post subject: Reply with quote

Thanks for the response.

All the imports in my class file are declared privately, including the layout module. The class, declared below the imports, contains the Bounds and Position type properties. I still got the errors...

Then I removed the import of the class file from the layout module, and all went fine. Damn those recursive imports.

Thanks again.
_________________
- Nick
- AIM: ndovelv
- Yahoo: ndovelv
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> General All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group