[英]warning: control reaches end of non-void function (gtk)
我不斷收到“警告:控制到達非void函數的結尾”的代碼:
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);
}
當我編譯上面的代碼時,我得到警告(即控制到達非void函數的結尾):
gui.c: warning: return type defaults to 'int'
gui.c: In function 'show_message':
gui.c: warning: control reaches end of non-void function
我如何擺脫這個警告?
謝謝。
您需要將show_message()
函數的返回值指定為void
,否則假定為int
。 像這樣:
static void show_message(GtkMessageType type, const char* text, const char* details)
{
/* ... */
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.