This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Confused by keil mdk struct alignment

typedef uint8_t BDADDR_t[6];
typedef struct
{
        uint8_t  State;
        BDADDR_t RemoteBDADDR;
        uint16_t DataPacketsQueued;
        uint16_t Handle;
        uint8_t  LinkType;
        uint8_t  CurrentIdentifier;
        bool     LocallyInitiated;
}ATTR_PACKED BT_HCI_Connection_t;
BT_HCI_Connection_t HCIConnection;

The address of HCIConnection is:0x1000004E and the memory data start from 0x1000004E is as following:
03 10 a3 15 83 15 00 00.
So I think the State = 03; the BDADDR is 00 15 83 15 a3 10, but the watch window show that the BDADDR is 00 00 15 83 15 a3.
So what should I do to get the correct value of a mix typed struct?

Another question:
Does the effect of #pragma pack(1) is the same as __packed ?
Thanks!

chris

0