|
3 registered members (AndrewAMD, Grant, Neb),
908
guests, and 6
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Accessing a PANEL froma struct
#410880
11/10/12 13:27
11/10/12 13:27
|
Joined: Nov 2011
Posts: 139 India
Yashas
OP
Member
|
OP
Member
Joined: Nov 2011
Posts: 139
India
|
typedef struct Applet
{
STRING * Name;
STRING * Author;
STRING * Version;
STRING * Description;
PANEL * Container;
void * Initilize;
void * Deinitlize;
int init;
}Applet;
if(is(applet->Container,SHOW) { reset(applet->Container,SHOW); return 0; }
Here I get a syntax error when I try to access a PANEL from the structure. Whats the bug there?? Thank && Regards
|
|
|
Re: Accessing a PANEL froma struct
[Re: Yashas]
#410883
11/10/12 14:03
11/10/12 14:03
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
I'm not sure if this is the problem but try the struct-name APPLET in stead of Applet. Kartoffel 
POTATO-MAN saves the day! - Random
|
|
|
Re: Accessing a PANEL froma struct
[Re: Yashas]
#410886
11/10/12 14:14
11/10/12 14:14
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
did you try what I suggested? I meant you use:
typedef struct
{
[...]
} APPLET;
and
APPLET* applet = sys_malloc(...);
Also make sure the pointers inside your struct are set to an object (PANEL* container to an existing PANEL*) or to an allocated memory block.
Last edited by Kartoffel; 11/10/12 14:15.
POTATO-MAN saves the day! - Random
|
|
|
Re: Accessing a PANEL froma struct
[Re: Kartoffel]
#410887
11/10/12 14:17
11/10/12 14:17
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
oh, wait! theres something missing  if(is(applet->Container,SHOW) ) { reset(applet->Container,SHOW); return 0; }
POTATO-MAN saves the day! - Random
|
|
|
Re: Accessing a PANEL froma struct
[Re: Kartoffel]
#410889
11/10/12 14:22
11/10/12 14:22
|
Joined: Apr 2008
Posts: 144 Germany | Niedersachsen (Lower...
Roxas
Member
|
Member
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
|
Try defining it without the *. I've got a pretty similar problem a couple of minutes ago. I wanted to add extra functionality to the panel's and made an "advanced panels" struct. looks like this:
typedef struct
{
PANEL* panel; // pointer to a standard panel
int anim; // Animation-Attribute for the panel
} advPANEL;
I defined it simply as:
advPANEL myAdvPanel;
myAdvPanel.panel = pan_create(NULL, 25);
if(myAdvPanel.panel != NULL)
{
myAdvPanel.panel.bmap = bmap_create("...");
myAdvPanel.panel.pos_x = ...
...
}
works like a charm. Cheers Roxas
Last edited by Roxas; 11/10/12 14:22.
|
|
|
Re: Accessing a PANEL froma struct
[Re: Roxas]
#410892
11/10/12 14:34
11/10/12 14:34
|
Joined: Nov 2011
Posts: 139 India
Yashas
OP
Member
|
OP
Member
Joined: Nov 2011
Posts: 139
India
|
LOL ,I forgot one bracket  And I get one more syntax error "if(applet->init)" I dont kno why
|
|
|
Re: Accessing a PANEL froma struct
[Re: Yashas]
#410897
11/10/12 15:05
11/10/12 15:05
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Ugh, seriously, guys if you have no idea what you are saying then don't say anything at all. Lite-C is confusing enough for beginners especially when it comes to pointers. We don't need anymore false information the like of "void is faster than function because herp derp".
@Kartoffel: The case doesn't matter. If you are not sure about an answer, test it yourself first. @Roxas: What you are describing is static vs dynamic memory allocation, however, even if Yashas hadn't allocated backing memory for his instance (which he has, as his second post shows), it wouldn't result in a compile time error.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
|