2012-04-18 91 views
2

我不斷收到「警告:控制到達非void函數的終結」與此代碼:警告:控制到達非void函數結束(GTK)

static show_message(GtkMessageType type, const char* text, const char* details) 
{ 
    GtkWidget *dialog; 

    g_assert(text); 

    dialog = gtk_message_dialog_new(NULL, DIALOG_FLAGS, type, GTK_BUTTONS_CLOSE, 
     "%s", text); 
    if (details) { 
     gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s", details); 
    } 
    gtk_dialog_run(GTK_DIALOG (dialog)); 
    gtk_widget_destroy(dialog); 
} 

當我編譯上面的代碼中,我得到警告(即控制達到非無效功能結束):

gui.c: warning: return type defaults to 'int' 
gui.c: In function 'show_message': 
gui.c: warning: control reaches end of non-void function 

如何擺脫此警告?

謝謝。

回答

6

您需要將show_message()函數的返回值指定爲void,否則將假定爲int。像這樣:

static void show_message(GtkMessageType type, const char* text, const char* details) 
{ 
    /* ... */ 
} 
相關問題