I'm writing a simple regular expression class to use in a project of mine.
When I compile it:
c++ -Wall -c RegExp.cpp
In file included from RegExp.hpp:8,
from RegExp.cpp:7:
/usr/include/regex.h:352: syntax error before `;'
/usr/include/regex.h:450: type specifier omitted for parameter
/usr/include/regex.h:450: parse error before `,'
/usr/include/regex.h:521: type specifier omitted for parameter
/usr/include/regex.h:521: parse error before `,'
/usr/include/regex.h:524: syntax error before `('
RegExp.cpp: In method `bool RegExp::match(const char *, const char *)':
RegExp.cpp:23: `struct regex_t' has no member named `re_nsub'
RegExp.cpp:30: `struct regex_t' has no member named `re_nsub'
RegExp.cpp:37: `struct regex_t' has no member named `re_nsub'
make: *** [RegExp.o] Error 1
Looking at line 352 in /usr/include/regex.h:
RE_TRANSLATE_TYPE translate;
/* Number of subexpressions found by the compiler. */
size_t re_nsub; <----- THIS IS LINE 352
/* Zero if this pattern cannot match the empty string, one else.
I wonder if this is a coinsidence?
My platform is RH6.2 upgraded with all the patches from RH.
c++ --version
egcs-2.91.66
I am trying to follow the example on page 411 of Linux Application
Development by Johnson and Troan.
Some of my code:
bool RegExp::match(const char* exp, const char* text) {
regex_t reg;
if (regcomp(®, exp, REG_ICASE)) {
regfree(®);
return false; // need exception or something
}
regmatch_t *pmatch;
pmatch = alloca(sizeof(regmatch_t) * reg.re_nsub); <--- LINE 23
Shurely there is a problem with regex.h? And not my code? This must be a
known problem! Anyone?
Go on, help an open source project :) Thanks
--
Daniel Barron - use [at jadeb.com] for personal replys.