如何为正确的PCRE设置标志? / g_regex_split_full:断言' regex!= NULL'失败

时间:2014-03-26 20:57:31

标签: makefile pcre glib ldflags

致电

tokens = g_regex_split (arv_gv_device_get_url_regex (), filename, 0);

我遇到了这个错误

(process:15239): GLib-WARNING **: unknown option bit(s) set
(process:15239): GLib-CRITICAL **: g_regex_split_full: assertion 'regex != NULL' failed

g_regex_split是glib的一部分。

在线搜索让我相信错误可能与编译器引用错误的pcre(= Perl Compatible Regular Expressions库)有关。 (请参阅此处对类似错误的讨论:https://groups.google.com/forum/#!topic/mu-discuss/cy_yKE6ivzM

我如何定义编译器选择的pcre?我在Makefile中设置了什么标志?


附加信息

$ locate libpcre.so
/lib/x86_64-linux-gnu/libpcre.so.3
/lib/x86_64-linux-gnu/libpcre.so.3.13.1
/usr/lib/x86_64-linux-gnu/libpcre.so

$ dpkg -s libpcre3
Package: libpcre3
Status: install ok installed
Priority: required
Section: libs
Installed-Size: 466
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Multi-Arch: same
Source: pcre3
Version: 1:8.31-2
Depends: libc6 (>= 2.14)
Pre-Depends: multiarch-support
Breaks: approx (<< 4.4-1~), cduce (<< 0.5.3-2~), cmigrep (<< 1.5-7~), galax (<< 1.1-7~), libpcre-ocaml (<< 6.0.1~), liquidsoap (<< 0.9.2-3~), ocsigen (<< 1.3.3-1~)
Conflicts: libpcre3-dev (<= 4.3-3)
Description: Perl 5 Compatible Regular Expression Library - runtime files
This is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
.
This package contains the runtime libraries.
Original-Maintainer: Mark Baker <mark@mnb.org.uk>

1 个答案:

答案 0 :(得分:0)

当您将NULL传递给regex != NULL时会发生g_regex_split断言失败,在您的情况下,这意味着arv_gv_device_get_url_regex的返回值为NULL。听起来你正在创建正则表达式而不检查以确保它实际上成功。

至于为什么g_regex_new没有成功,你没有包含那些代码所以很难回答,但关于“未知选项位设置”的警告肯定提供了线索。仔细查看您传递给g_regex_new的标志,并找出导致警告修复的标记,这可能会使g_regex_new返回实际实例而不是{{1}应该修复断言失败。当然,您仍应在运行时检查返回值并正确处理错误,而不是让它们变成断言失败...