about sizeof(struct st)..

Questions, comments and discussion about the Game Editor development.

about sizeof(struct st)..

Postby linjichao » Sat Apr 24, 2010 5:03 am

i try to get sizeof a self-define struct type, but i confuse about result...

example,
typedef struct st
{
char* name;
struct st* next;
}ST;

sprintf(text, "result is:%d", sizeof(ST));

result is:0x18

why??? it should 0x8,isn't?
linjichao
 
Posts: 35
Joined: Fri Jan 22, 2010 10:13 am
Score: 0 Give a positive score

Re: about sizeof(struct st)..

Postby akr » Sat Apr 24, 2010 7:47 am

You cant rely on that. Its about structure alignment of the compiler / interpreter. Different systems will give u always different values.

Andreas
Co-Developer of GE engine

If u are interrested in new features of apple or android ge engines check the engine support website game-editor.net regulary.
akr
 
Posts: 453
Joined: Thu Feb 25, 2010 7:56 pm
Location: Germany, Ulm
Score: 40 Give a positive score

Re: about sizeof(struct st)..

Postby linjichao » Sat Apr 24, 2010 9:58 am

how can i get the sizeof the struct ?
is there have any way to do?
linjichao
 
Posts: 35
Joined: Fri Jan 22, 2010 10:13 am
Score: 0 Give a positive score

Re: about sizeof(struct st)..

Postby makslane » Sat Apr 24, 2010 3:47 pm

Are you trying to port for 64bits?
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: about sizeof(struct st)..

Postby linjichao » Wed Apr 28, 2010 4:02 pm

32 bits

i have another question...
there have any way to translate function pointer where define in ge script to build-in function in ge?
linjichao
 
Posts: 35
Joined: Fri Jan 22, 2010 10:13 am
Score: 0 Give a positive score

Re: about sizeof(struct st)..

Postby makslane » Wed Apr 28, 2010 4:26 pm

The functions defined in the script are not compiled in native instruction codes.
So, you can't call using a function pointer.

If you are compiling the normal 32bit version, I think the wrong struct size can be a bug of the script engine.
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest