View previous topic :: View next topic |
Author |
Message |
ndove
Joined: 12 Oct 2004 Posts: 6 Location: Las Vegas
|
Posted: Sun Oct 24, 2004 12:58 am Post subject: Forward References? |
|
|
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 |
|
|
larsivi Site Admin
Joined: 27 Mar 2004 Posts: 453 Location: Trondheim, Norway
|
Posted: Sun Oct 24, 2004 1:24 am Post subject: |
|
|
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 |
|
|
ndove
Joined: 12 Oct 2004 Posts: 6 Location: Las Vegas
|
Posted: Sun Oct 24, 2004 3:07 am Post subject: |
|
|
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 |
|
|
|