-1

私の 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'

................................................................... ...... これらの警告を解決する方法を教えてください。

ありがとうございました。

4

1 に答える 1

0

まず、ヘッダーファイルがない場合、メインまたはその他の関数で使用されるすべての関数は、ほとんどがその上で宣言されます。

void function();

int main() {
    function();
}

ヘッダーファイルがある場合 (私が尋ねたにもかかわらず提供しなかったので、そうではないと仮定します)、そこですべての関数を宣言し、ヘッダーファイルをインクルードする必要があります。

//something.h

void function();

//something.c

#include "something.h"
int main() {
    function();
}
于 2012-04-18T21:07:20.090 に答える