警告:函数GTK2的隐式声明

时间:2012-04-18 20:51:47

标签: c

我的c代码使用'show_error_message'(GTK2)

#include <gnome.h>
#include <profiles/audio-profile.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

..........................................................................

static void error_cb(GstBus *bus, GstMessage *message, gpointer user_data)
{
    GError *error = NULL;
    GstElement *pipeline = user_data;
    g_assert(pipeline);

    /* Make sure the pipeline is not running any more */
    gst_element_set_state (pipeline, GST_STATE_NULL);

    gst_message_parse_error(message, &error, NULL);
    show_error_message(_("GStreamer runtime error."), error->message);
    g_error_free(error);
}

得到这些警告:

warning: implicit declaration of function 'show_error_message'

#include <config.h>
#include <gnome.h>
#include <gconf/gconf-client.h>
#include <math.h>

.................................................

        /* Initizialize Gconf */
    if (!gconf_init(argc, argv, &err)) {
        char *details;
        details = g_strdup_printf(_("%s\n\nChanges to the settings won't be saved."), err->message);
        show_warning_message(_("Failed to init GConf!"), details);
        g_error_free(err); 
        g_free(details);
        err = NULL;
    } else {
        gconf_client_set_global_default_error_handler((GConfClientErrorHandlerFunc)gconf_error_handler);
        gconf_client_set_error_handling(gconf_client_get_default(),  GCONF_CLIENT_HANDLE_ALL);
        gnome_media_profiles_init(gconf_client_get_default());
    }

得到这些警告:

warning: implicit declaration of function 'gnome_media_profiles_init'

............................................... ......... 你能告诉我如何解决这些警告吗?

谢谢。

1 个答案:

答案 0 :(得分:0)

首先,如果你没有头文件,那么在main或其他函数中使用的所有函数,大多数都在它上面声明。

void function();

int main() {
    function();
}

如果你有一个头文件(假设你没有,因为你没有提供我,即使我问过)你应该在那里声明所有的功能,然后包括头文件。

//something.h

void function();

//something.c

#include "something.h"
int main() {
    function();
}