本文介绍了警告:控制到达非void函数结束(GTK)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不断收到警告:控制到达非void函数的终结与此code:
I keep getting 'warning: control reaches end of non-void function' with this code:
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);
}
当我编译上面code我得到警告(即控制到达非void函数结束时):
When I compile the above code I get Warning (ie control reaches end of non-void function):
gui.c: warning: return type defaults to 'int'
gui.c: In function 'show_message':
gui.c: warning: control reaches end of non-void function
我
如何才能摆脱这种警告?
How can I get rid of this warning?
感谢。
推荐答案
您需要指定 show_message的返回值()
功能无效
,否则假定 INT
。像这样的:
You need to specify the return value of the show_message()
function as void
, otherwise it is assumed int
. Like this:
static void show_message(GtkMessageType type, const char* text, const char* details)
{
/* ... */
}
这篇关于警告:控制到达非void函数结束(GTK)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!