( >= gcc 4.2 ),建议用 ISR(XXXX_vect)形式。
想问老师一个问题,关于GCC 4.3.0 处理“结构对齐”的问题。
用winavr20050214编译lwip1.3到时候,在cc.h中如下定义没问题。 gcc 3.4.3 : #define PACK_STRUCT_FIELD(x) x __attribute__((packed)) #define PACK_STRUCT_STRUCT __attribute__((packed)) #define PACK_STRUCT_BEGIN #define PACK_STRUCT_END
使用: PACK_STRUCT_BEGIN struct ip_addr { PACK_STRUCT_FIELD(u32_t addr); } PACK_STRUCT_STRUCT; PACK_STRUCT_END
但在winavr20080610中这样定义,使用就出问题了, 提示 warning: 'packed' attribute ignored for field of type 'u32_t'
我在帮助文件里找到了相关的说明:
— Macro: HANDLE_SYSV_PRAGMA
Define this macro (to a value of 1) if you want the System V style pragmas #pragma pack(<n>) and #pragma weak <name> [=<value>] to be supported by gcc.
The pack pragma specifies the maximum alignment (in bytes) of fields within a structure, in much the same way as the __aligned__ and __packed__ __attribute__s do. A pack value of zero resets the behavior to the default.
A subtlety for Microsoft Visual C/C++ style bit-field packing (e.g. -mms-bitfields) for targets that support it: When a bit-field is inserted into a packed record, the whole size of the underlying type is used by one or more same-size adjacent bit-fields (that is, if its long:3, 32 bits is used in the record, and any additional adjacent long bit-fields are packed into the same chunk of 32 bits. However, if the size changes, a new field of that size is allocated).
If both MS bit-fields and __attribute__((packed)) are used, the latter will take precedence. If __attribute__((packed)) is used on a single field when MS bit-fields are in use, it will take precedence for that field, but the alignment of the rest of the structure may affect its placement.
The weak pragma only works if SUPPORTS_WEAK and ASM_WEAKEN_LABEL are defined. If enabled it allows the creation of specifically named weak labels, optionally with a value.
所以我在makefile里面同时也定义了这个宏 CDEFS = -DHANDLE_SYSV_PRAGMA=1 但还是会出问题,请问我该如何解决这警告呢 ? 谢谢。
|