what repremand proceed initialize unequivocally infinite struct?


in the formula used have something this:



   *(controller->bigstruct) = ( struct bigstruct ){ 0 };


this used work great, following upgraded versions gcc astonishing started observant smoke-stack s. looking during assembly, aged gcc formula (2.x) fundamentally doing this:



memset(controller->bigstruct, 0, sizeof(struct bigstruct));


the new gcc (3.4.x) doing this



   struct bigstruct temp = { 0 };
controller->bigstruct = temp;


after reviewing c99 spec, i why; c99 fundamentally requires opposite structures exist stack. it's good concept, nonetheless structure 4 megabytes large, wholly ever commanded exist heap!



we've resorted origination the possess 'initialize' duty definitely sets members, nonetheless that's dizzy maintain headache. i don't cruise memset repremand solution, since i can't know bit-value 0 an suitable 0 value form ( nit-picking, i know, nonetheless there are; i don't mind compiler does it, since can know )



what "correct", during slightest best, proceed initialize infinite structure this?



to furthur explain since i cruise memset isn't solution: manners initialization members definitely initialized same stationary initialization, follows:
- pointer type, initialized zero pointer;
- arithmetic type, initialized ( certain unsigned ) zero;
...



'memset' set memory bit-pattern zero, isn't indispensably same thing. suspect component doesn't ieee floating indicate numbers. unusual, nonetheless upheld c. illustration 0.0 doesn't have meant "all-bits zero", anything accessible processor.



Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members