Поставил: libpcre++0, libpcre++-dev, libpcre3-dbg, libpcre3-dev, libpcre3:i386, libpcrecpp0, libpcre3
IDE: Code::Blocks
Написал следующий код:
#include <iostream>
#include <pcre.h>
using namespace std;
int main( void )
{
char pattern[] = "e";
char str[] = "test";
const unsigned char *tables = NULL;
setlocale (LC_CTYPE, (const char *) "ru.");
tables = pcre_maketables();
pcre *re;
int options = 0;
const char *error;
int erroffset;
re = pcre_compile((char *) pattern, options, &error, &erroffset, NULL);
if (!re)
{
cout << "Failed\n";
}
else
{
int count = 0;
int ovector[30];
count = pcre_exec(re, NULL, (char *) str, 4, 0, 0, ovector, 30);
if (!count)
{
cout << "No match\n";
}
else
{
for (int c = 0; c < 2 * count; c += 2)
{
if (ovector[c] < 0)
{
cout << "<unset>\n";
}
else
{
cout << ovector[c] << "/" << ovector[c + 1] << "\n";
}
}
}
}
return 0;
}
Добавил в параметры линковщика -lpcre
При Rebuild возникает следующее:
(и в релизе, и в дебаге)
-------------- Build: Release in lab01 ---------------
Compiling: main.cpp
/main.cpp: В функции «int main()»:
/main.cpp:59:84: предупреждение: passing NULL to non-pointer argument 6 of «int pcre_exec(const pcre*, const pcre_extra*, const char*, int, int, int, int*, int)» [-Wconversion-null]
/main.cpp:39:26: предупреждение: variable «tables» set but not used [-Wunused-but-set-variable]
Linking console executable: bin/Release/lab01
Output size is 10,21 KB
Process terminated with status 0 (0 minutes, 0 seconds)
2 errors, 0 warnings
Предупреждения, но порождают ошибки.
При Build and Run такого не возникает.
Пользователь решил продолжить мысль 26 Ноября 2011, 02:51:54:
(тема была немного обновлена, потому как появились другие вопросы)