Posted By: Kartoffel
sizeof() behaviour - 12/07/15 10:52
Why isn't this printing out 4096?
I'm questioning my sanity right now.
obj pluto; printf ("%I",(int)sizeof (pluto));
obj.shit [0]=0; //should this work ?
Obj * A; A = sys_malloc(sizeof((*Obj)));
/////////////////////////////// #include <acknex.h> #include <default.c> /////////////////////////////// struct _OBJ { int what; var superwhat; //int watchYourLanguage[4]; }; typedef struct _OBJ OBJ; OBJ myobj; void main() { int size = 5+(sizeof(OBJ))*5; printf("%d",size); // returns 5 }
#define SIZE 1000 typedef struct { int member[SIZE]; } Object; Object *ptr = (Object *) sys_malloc( sizeof(Object) + (SIZE * sizeof(int)) ); <...> sys_free(ptr);
/////////////////////////////// #include <acknex.h> #include <default.c> /////////////////////////////// //works fine<---------- struct objects1 { int a[1024]; }obj1,obj2; //typedef doesnt work <------------ typedef struct objects2 { int a[1024]; }objects2; function main() { printf("objects1 %d,%d",(long)sizeof(obj1),(long)sizeof(obj2));//works fine<---------- printf("objects2 %d",(long)sizeof(objects2));//typedef doesnt work <------------ }
obj.stool[0]=0; //should this work ?
/////////////////////////////// #include <acknex.h> #include <default.c> /////////////////////////////// //works fine<---------- struct objects1 { int a[1024]; }obj1,obj2; //typedef doesnt work <------------ typedef struct objects2 { int a[1024]; }objects2; function main() { obj1.a[0]=100;//<----- correct objects2.a[0]=100;//<----syntax error }
struct objects2 { int a[1024]; }
objects2 obj3;
obj pluto; printf ("%I",(int)sizeof (pluto));
typedef struct { int stuff [1024]; }obj;