c - 警告 : implicit declaration of function GTK2

标签 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'

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

谢谢。

最佳答案

首先,如果您没有头文件,则 main 或其他函数中使用的所有函数大多数都在其上方声明。

void function();

int main() {
    function();
}

如果您有一个头文件(假设您没有,因为即使我要求,您也没有向我提供),您应该在那里声明所有函数,然后包含该头文件。

//something.h

void function();

//something.c

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

关于c - 警告 : implicit declaration of function GTK2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10217770/

相关文章:

c - 4 变量映射到数组

c - 多线程向列表无限循环插入元素

c - execvp() 和不完整的多参数命令的问题

c - 如何检查 C 中的某些字符

c - 双参数数组排序

c - 调整存储为 'strided' 数组 : can I make this bilinear interpolation faster? 的图像的大小

c - 抑制 "Insert diskette to drive X:"

c - 使用 fgets() 时将值放入链表 header 中

c - 动态制作结构数组

c - 这段代码的 Swift 3.1 等效逻辑