Problems with regex.h in an extension module

I am working on embedding ruby into a C++ application but I cannot get
the app to compile because of the naming of regex.h in
/usr/lib/ruby/1.8/i686-linux-gnu. It conflicts with
/usr/include/regex.h. Below I have pasted the compile error that I get.

make[2]: Entering directory /home/michael/dev/kahakai/kahakai/src' g++ -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/include/python2.2 -I/usr/X11R6/include -I/usr/include/freetype2 -DSHAPE -DXINERAMA -DRANDR -DRENDER -DXFT -DINTERLACE -DPIXMAP -DPYTHON -DRUBY -I/usr/lib/ruby/1.8/i686-linux-gnu -DDEFAULTSTYLE=\"/usr/local/share/kahakai/styles/Default.style\" -DDEFAULTMENU=\"/usr/local/share/kahakai/menu\" -DDEFAULTACTION=\"/usr/local/share/kahakai/actions/action\" -DDEFAULTRCFILE=\"/usr/local/share/kahakai/config\" -DDEFAULTSCRIPTDIR=\"/usr/local/share/kahakai/scripts\" -DPKGDATADIR=\"/usr/local/share/kahakai\" -DDEFAULTSCRIPTCONFIG=\"/usr/local/share/kahakai/scripts/config.py\" -g -O2 -I/usr/X11R6/include -g -O0 -ffast-math -pipe -Wall -pthread -c main.cc In file included from Resources.hh:42, from Screen.hh:50, from Waimea.hh:158, from main.cc:18: Regex.hh: In destructorRegex::~Regex()’:
Regex.hh:33: `regfree’ undeclared (first use this function)
Regex.hh:33: (Each undeclared identifier is reported only once for each
function it appears in.)

regfree is defined in /usr/include/regex.h. How can I work around this problem?

···


Michael
GnuPG Fingerprint: 4C56 7C23 8BD9 8B39 C4D4 B8F3 42FB 3634 31B5 E963

I am working on embedding ruby into a C++ application but I cannot get
the app to compile because of the naming of regex.h in
/usr/lib/ruby/1.8/i686-linux-gnu. It conflicts with
/usr/include/regex.h. Below I have pasted the compile error that I get.

[snip]

regfree is defined in /usr/include/regex.h. How can I work around this problem?

You will have to make a wrapper around ‘/usr/include/regex.h’, so
that thier names doesn’t clash.
Do like this:

Make a .H file, with the same interface as ‘/usr/include/regex.h’
perhaps named differently.

Make a .CPP file, which redirects all calls to ‘/usr/include/regex.h’
Only link this .CPP file with the regex library.

The same technique (just with classes instead)
http://www.gotw.ca/gotw/028.htm

···

On Sun, 15 Jun 2003 10:30:28 +0900, Michael Brailsford wrote:


Simon Strandgaard

You will have to make a wrapper around ‘/usr/include/regex.h’, so
that thier names doesn’t clash.

It would be much more preferable to rename ruby’s regex.h to not clash
with a standard header in /usr/include.

···


Michael
GnuPG Fingerprint: 4C56 7C23 8BD9 8B39 C4D4 B8F3 42FB 3634 31B5 E963