TYPEs and circular references

New to FreeBASIC? Post your questions here.
McLovin
Posts: 82
Joined: Oct 21, 2008 1:15
Contact:

TYPEs and circular references

Postby McLovin » Dec 09, 2009 3:02

I have a situation where an element in one TYPE structure is dimmed as the second TYPE. In the second TYPE, there is a member that is declared as the first TYPE.

here is some simple code that demonstrates:

Code: Select all

Type MyType1
   pSomeVar1 As MyType2 Ptr
End Type

Type MyType2
   pSomeVar2 As MyType1 Ptr
End Type


Do you guys have any idea how to tackle this chicken and egg ptoblem?

Thanks,
stylin
Posts: 1253
Joined: Nov 06, 2005 5:19

Postby stylin » Dec 09, 2009 4:02

This is probably what you want:

Code: Select all

Type MyType2_ as MyType2

Type MyType1
   pSomeVar1 As MyType2_ Ptr
End Type

Type MyType2
   pSomeVar2 As MyType1 Ptr
End Type
McLovin
Posts: 82
Joined: Oct 21, 2008 1:15
Contact:

Postby McLovin » Dec 09, 2009 12:33

Thanks stylin, that was exactly the fix that I needed. I haven't used the TYPE alias' before. Pretty cool.

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 5 guests