2010-09-24 88 views
0

我翻看一個C源代碼(pjsip),我找到了這個結構。我不知道如何構想。C結構靜態

static struct user_agent 
{ 
    pjsip_module  mod; 
    pj_pool_t  *pool; 
    pjsip_endpoint *endpt; 
    pj_mutex_t  *mutex; 
    pj_hash_table_t *dlg_table; 
    pjsip_ua_init_param param; 
    struct dlg_set free_dlgset_nodes; 

} mod_ua = 
{ 
    { 
    NULL, NULL,   /* prev, next.   */ 
    { "mod-ua", 6 },  /* Name.    */ 
    -1,    /* Id    */ 
    PJSIP_MOD_PRIORITY_UA_PROXY_LAYER, /* Priority  */ 
    &mod_ua_load,  /* load()    */ 
    NULL,   /* start()    */ 
    NULL,   /* stop()    */ 
    &mod_ua_unload,  /* unload()    */ 
    &mod_ua_on_rx_request, /* on_rx_request()   */ 
    &mod_ua_on_rx_response, /* on_rx_response()   */ 
    NULL,   /* on_tx_request.   */ 
    NULL,   /* on_tx_response()   */ 
    &mod_ua_on_tsx_state, /* on_tsx_state()   */ 
    } 
}; 
+4

只要做自然而然的事。 – Powertieke 2010-09-24 13:30:31

+0

什麼是問題/問題? – nos 2010-09-24 13:36:56

+0

就像Kev說的那樣:它不是靜態類型('struct user_agent'),而是變量('mod_ua')。 – pmg 2010-09-24 14:22:16

回答

2

不是一個特別明確的問題,但我認爲你有一個問題是結構正在宣佈和使用在同一語句。如何:

struct user_agent { 
    .... 
} 

static struct user_agent mod_ua = .... 

那有什麼更清楚的?

ķ

+0

感謝解決方案! – BaluEdo 2010-09-24 13:48:10

0

很難是沒有結構的定義確定的,但我覺得有什麼情況是,mod成員(這是pjsip_module類型)正在初始化,以及mod_ua其他成員都沒有顯式初始化(​​這意味着它們將被設置爲零,因爲這是一些成員初始化時發生的情況,而不是其他情況)。內在的大括號是線索。看看pjsip_module的定義 - 它是否與您擁有的值相符?