On 08/05/2012 01:16:45 PM, Leon Timmermans wrote:
> On Sun, Aug 5, 2012 at 5:23 AM, Geoffrey Leach <ge...@hughes.net>
> wrote:
> > So, what am I doing wrong?
> >
> > FWIW, the problem that gives rise to this question
> >
> > g++ ... TagLib.c
> > In file included from /usr/include/c++/4.2/bits/basic_ios.h:44,
> >                  from /usr/include/c++/4.2/ios:50,
> >                  from /usr/include/c++/4.2/ostream:45,
> >                  from /usr/local/include/taglib/tbytevector.h:33,
> >                  from /usr/local/include/taglib/
> tbytevectorlist.h:30,
> >                  from TagLib.c:178:
> > /usr/include/c++/4.2/bits/locale_facets.h:4420:40: error: macro
> > "do_open"
> > requires 7 arguments, but only 2 given
> > /usr/include/c++/4.2/bits/locale_facets.h:4486:55: error: macro
> > "do_open"
> > requires 7 arguments, but only 2 given
> >
> > I'm guessing (no way to verify) that the problem arises out of the
> fact
> > that the tester is running v4.2 of g++, while I have 4.7.0
> >
> > I'm running Fedora 17
> 
> The problem has nothing to do with perl versions. It is simple and
> highly annoying: perl has a do_open macro, but libstdc++ has do_open
> methods. This clashes in ugly ways. The simplest way to deal with 
> this
> is to undefine do_open before loading any C++ headers, but you may 
> hit
> other defines (in particular do_close). Perl's API is made for the
> flat namespaces of C, not the hierarchical namespacese of C++. 
> Macro's
> that are almost sane in C turn out to be highly problematic in C++.
> 
> It gets even worse on Windows, where perl will define short macros
> such as read() and write() by default. The NO_XSLOCKS define is your
> friend there.

Leon, many thanks.  After testing, here's what I've come up with, 
written by the original author of the package. In the master .xs file, 
it appears to work, surrounding the problem file.

#ifdef do_open(a,b,c,d,e,f,g)
#undef do_open(a,b,c,d,e,f,g)
#undef do_open
#undef do_close(a,b)
#undef do_close
#endif
#include "apeitem.h"
#ifndef do_open
#define do_open                 Perl_do_open
#define do_open(a,b,c,d,e,f,g)  Perl_do_open(aTHX_ a,b,c,d,e,f,g)
#define do_close                Perl_do_close
#define do_close(a,b)           Perl_do_close(aTHX_ a,b)
#endif




Reply via email to