MK60 KDS 3.x Cross ARM compiler question

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

MK60 KDS 3.x Cross ARM compiler question

730 次查看
henrynguyen
Contributor IV

Hi All,

we used Keil on Cortex M3 project in the past and able to declare the packed typedef struct as:

typedef __pack struct
{
BYTE byPriority;
BYTE byMsgType;
BYTE bySrcDvc;
BYTE byDstDvc;
WORD wPointer;
BYTE *byBuffer;
} CAN_BUFFER;

then, now we are using KDS 3.x and Cross ARM C compiler.  I have changed the typedef to the following 

typedef struct
{
BYTE byPriority;
BYTE byMsgType;
BYTE bySrcDvc;
BYTE byDstDvc;
WORD wPointer;
BYTE *byBuffer;
} CAN_BUFFER __attribute__((packed));

however, the compiler kicked out the warning message bold highlighted below:

Building file: ../Sources/main.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -g3 -I"D:/ThruBit/GitRepositories/GIT_WS_KDS_New/MLSB_v1.0.0/Static_Code/PDD" -I"D:\ThruBit\GitRepositories\GIT_WS_KDS_New\MLSB_v1.0.0\Sources\Lib_Core" -I"D:\ThruBit\GitRepositories\GIT_WS_KDS_New\MLSB_v1.0.0\Sources\Lib_ComProtocol" -I"D:/ThruBit/GitRepositories/GIT_WS_KDS_New/MLSB_v1.0.0/Static_Code/IO_Map" -I"D:/ThruBit/GitRepositories/GIT_WS_KDS_New/MLSB_v1.0.0/Sources" -I"D:/ThruBit/GitRepositories/GIT_WS_KDS_New/MLSB_v1.0.0/Generated_Code" -std=c99 -MMD -MP -MF"Sources/main.d" -MT"Sources/main.o" -c -o "Sources/main.o" "../Sources/main.c"
In file included from ../Sources/main.c:49:0:
D:\GitRepositories\GIT_WS_KDS_New\MLSB_v1.0.0\Sources\Lib_ComProtocol/CanProtocol.h:73:1: warning: 'packed' attribute ignored [-Wattributes]  <<<<<<< warnning here
} CAN_BUFFER __attribute__((packed));

can you please help me understand the correct way to declare a packed typedef struct?

what is the meaning of "warning: 'packed' attribute ignored [-Wattributes]"?

Thanks,

Henry

1 回复

523 次查看
henrynguyen
Contributor IV

wow, i searched and found this link posted the solution by Mark Butcher:

https://community.nxp.com/message/846440?commentID=846440#comment-846440 

i tried it and it work for me.

Thanks,

Henry