从不兼容的指针类型(结构)分配c

时间:2012-12-28 21:17:21

标签: pointers struct gtk

用于结构

typedef struct Recording_Settings recording_settings;
struct Recording_Settings
{
    gchar *profile;
    gchar *destination;
};

recording_settings rec_settings;

我尝试这样做时会收到警告

static void profile_combo_change_cb(GtkComboBox *combo, gpointer userdata)
{
    GtkTreeIter iter;
    GtkTreeModel *model;

    /* Grab the encoding profile choosen */
    model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
    if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) {
        gchar *media_type;
        gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 0, &media_type, -1);
        rec_settings.profile = rb_gst_get_encoding_profile(media_type); // Warning: assignment from incompatible pointer type
        g_free (media_type);
    }
}

我误解或遗漏了什么吗?

感谢。

1 个答案:

答案 0 :(得分:0)

rb_gst_get_encoding_profile的类型似乎是

GstEncodingProfile *rb_gst_get_encoding_profile (const char *media_type);

但您将其返回值分配给gchar *

GstEncodingProfilestruct类型,据我所知(typedef struct _GstEncodingProfile GstEncodingProfile;),gchar可能是typedef的字符类型(很可能是来自glib的typedef char gchar;。因此类型不兼容。