Re: [GD-Windows] using typedef to create aligned types
Brought to you by:
vexxed72
From: Daniel G. <dgl...@cr...> - 2004-12-02 01:40:12
|
Daniel Glastonbury wrote: > Andras Balogh wrote: > >> Let Fred be: >> >> class Fred { >> public: >> int helloiamfred; >> }; >> >> then sizeof(Fred) will be 4 >> >> but if I align the same class to 16 bytes: >> >> class __declspec(align(16)) Fred { >> public: >> int helloiamfred; >> }; >> >> then sizeof(Fred) will be 16!!! >> >> > No it won't. I've just been told by a friend that VS.Net spits out the following: * class Fred* *{* *public:* *int helloiamfred;* *};* *class __declspec(align(16)) FredX {* *public:* *int helloiamfred;* *};* *int s1 = sizeof(Fred);* *int s2 = sizeof(FredX);* *s1 is 4, s2 is 16 * His explanation was to do with operator new[] failing if it didn't adjust the size. But my question is then, how does operator new cope with the typedef version? Incorrectly? cheers DanG -- Dan Glastonbury, Senior Programmer, The Creative Assembly PO Box 883 Fortitude Valley, QLD, Australia. 4006 T: +617 3252 1359 W: http://www.creative-assembly.com.au `Pour encourjay lays ortras' |