Board index » cppbuilder » Data alignment problem in C++2007
Simon Hooper
![]() CBuilder Developer |
Data alignment problem in C++20072007-09-05 10:57:17 PM cppbuilder18 I think I have encountered a problem with data alignment in C++007 with update 2. If the following code example is run, with the project data alignment set option set to 'Double Word', the size of foo (=24) doesn't equal foo2 (=16). Under BDS2006, the size of foo and foo2 are the same (=16) #pragma argsused int main(int argc, char* argv[]) { struct foo { char c; double dval; int ival; }; #pragma pack(push, 4) struct foo2 { char c; double dval; int ival; }; #pragma pack(pop) cout << "size of foo:" << sizeof( foo ) << endl; cout << "size of foo2:" << sizeof( foo2 ) << endl; getch(); return 0; } Simon |