#pragma pack(push, 4)
#pragma pack(pop)
Code::Blocks + MinGW и команды препроцессора
Код:
и директивы для помещения данных в shared секцию? Если есть, то какие?
http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc.pdf) написано:
В документации на gcc-4.3.2 (
Цитата:
5.52.7 Structure-Packing Pragmas
For compatibility with Win32, GCC supports a set of #pragma directives which change the
maximum alignment of members of structures (other than zero-width bitfields), unions, and
classes subsequently defined. The n value below always is required to be a small power of
two and specifies the new alignment in bytes.
1. #pragma pack(n) simply sets the new alignment.
2. #pragma pack() sets the alignment to the one that was in effect when compilation
started (see also command line option ‘-fpack-struct[=<n>]’ see Section 3.18 [Code
Gen Options], page 221).
3. #pragma pack(push[,n]) pushes the current alignment setting on an internal stack
and then optionally sets the new alignment.
4. #pragma pack(pop) restores the alignment setting to the one saved at the top of the
internal stack (and removes that stack entry). Note that #pragma pack([n]) does not
influence this internal stack; thus it is possible to have #pragma pack(push) followed
by multiple #pragma pack(n) instances and finalized by a single #pragma pack(pop).
For compatibility with Win32, GCC supports a set of #pragma directives which change the
maximum alignment of members of structures (other than zero-width bitfields), unions, and
classes subsequently defined. The n value below always is required to be a small power of
two and specifies the new alignment in bytes.
1. #pragma pack(n) simply sets the new alignment.
2. #pragma pack() sets the alignment to the one that was in effect when compilation
started (see also command line option ‘-fpack-struct[=<n>]’ see Section 3.18 [Code
Gen Options], page 221).
3. #pragma pack(push[,n]) pushes the current alignment setting on an internal stack
and then optionally sets the new alignment.
4. #pragma pack(pop) restores the alignment setting to the one saved at the top of the
internal stack (and removes that stack entry). Note that #pragma pack([n]) does not
influence this internal stack; thus it is possible to have #pragma pack(push) followed
by multiple #pragma pack(n) instances and finalized by a single #pragma pack(pop).
Однако текущая версия MinGW работает с gcc-g++-3.4.5 (насколько я понял, она не поддерживает эти директивы). Можно пытаться ставить альфы компонентов MinGW. Наверно, отсюда:
http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=241304
Цитата: Нездешний
Есть ли аналоги
и директивы для помещения данных в shared секцию? Если есть, то какие?
Код:
#pragma pack(push, 4)
#pragma pack(pop)
#pragma pack(pop)
и директивы для помещения данных в shared секцию? Если есть, то какие?
Я может быть чего-то недопонял, но если речь идёт о выравнивании, то нативное выравнивание для gcc выглядит так:
Код:
TYPE Object __attribute__((__aligned__(X)));
.. после чего объект Object будет выровнен на границу X байт.
Насчёт прагм не знаю..