问题描述
我是C的新手。我正在尝试将键值对写入glib哈希表。执行插入语句时,以下代码失败。 gdb
仅提供有关该错误的稀疏信息(请参见下文)。
struct _struct_with_properties{
GHashTable *properties;
};
[...]
// init
_struct_with_properties str = g_slice_new0(_struct_with_properties);
str->properties = g_hash_table_new_full(g_str_hash,g_str_equal,g_free,g_free);
// insert entry
char *key = "key123";
char *value = "value";
g_hash_table_insert(str->properties,g_strdup(key),g_strdup(value));
程序收到信号SIGSEGV,分段错误。 0x00007ffff78c6225 in ?? ()来自 /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
我在make文件中的glib配置是:
GLIB2_CFLAGS = -pthread -I / usr / include / glib-2.0 -I / usr / lib / x86_64-linux-gnu / glib-2.0 / include
GLIB2_LIBS = -lgthread-2.0 -pthread -lgio-2.0 -lgobject-2.0 -lglib-2.0
这是配置问题还是我的代码不正确?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)