Firefly开源社区

标题: 带中括号的枚举值是怎么回事 [打印本页]

作者: nevermore    时间: 2016-4-23 22:02
标题: 带中括号的枚举值是怎么回事
/// Possible states of the QPPS task
enum
{
    /// Disabled state
    QPPS_DISABLED,
    /// Idle state
    QPPS_IDLE,
    /// Connected state
    QPPS_CONNECTED,

    /// Number of defined states.
    QPPS_STATE_MAX,
};

/// Disabled State handler definition.
const struct ke_msg_handler qpps_disabled[] =
{
    {QPPS_CREATE_DB_REQ,        (ke_msg_func_t) qpps_create_db_req_handler}
};

/// Idle State handler definition.
const struct ke_msg_handler qpps_idle[] =
{
    {QPPS_ENABLE_REQ,           (ke_msg_func_t) qpps_enable_req_handler}
};

/// Connected State handler definition.
const struct ke_msg_handler qpps_connected[] =
{
    {QPPS_DATA_SEND_REQ,    (ke_msg_func_t) qpps_data_send_req_handler},
    {GATT_WRITE_CMD_IND,    (ke_msg_func_t) gatt_write_cmd_ind_handler},
    {GATT_NOTIFY_CMP_EVT,   (ke_msg_func_t) gatt_notify_cmp_evt_handler},
};

/// Specifies the message handler structure for every input state.
const struct ke_state_handler qpps_state_handler[QPPS_STATE_MAX] =
{
    [QPPS_DISABLED]       = KE_STATE_HANDLER(qpps_disabled),
    [QPPS_IDLE]           = KE_STATE_HANDLER(qpps_idle),
    [QPPS_CONNECTED]    = KE_STATE_HANDLER(qpps_connected),
};

最后一个结构体里,枚举值加上中括号再赋值是什么用法
作者: 牛头    时间: 2016-4-25 09:22
:lol 编译器的特性,给数组里指定的变量附值。




欢迎光临 Firefly开源社区 (https://dev.t-firefly.com/) Powered by Discuz! X3.1