maybe somebody can help me to understand. why this error occurs. I am trying to build C++ code, that use using Inline::CPP.
Here is the example:
#!/usr/bin/env perl
package main v0.1.0;
use strict;
use warnings;
use Inline(
CPP => <<'CPP',
#undef seekdir
#include <sstream>
CPP
# ccflags => '-std=c++11',
ccflags => '-std=gnu++11',
clean_after_build => 0,
clean_build_area => 0,
);
1;
__END__
This code compiled without errors under linux, but under strawberry perl 5.26.2 x64 it produce following error:
"D:\devel\perl\perl\bin\perl.exe" -MExtUtils::Command -e mv -- _2_pl_0f1f.xsc _2_pl_0f1f.c
g++ -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -D__USE_MINGW_ANSI_STDIO -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields -xc++ -c -I"D:/downloads/cpp-adaptive/cppAdaptive2/inline-src" -std=gnu++11 -s -O2 -DVERSION=\"0.00\" -DXS_VERSION=\"0.00\" "-ID:\devel\perl\perl\lib\CORE" _2_pl_0f1f.c
In file included from _2_pl_0f1f.xs:11:0:
D:\devel\perl\perl\lib\CORE/perl.h:3544:45: error: expected ')' before '*' token
# define PERL_GET_THX ((PerlInterpreter *)PERL_GET_CONTEXT)
^
D:\devel\perl\perl\lib\CORE/perl.h:3544:45: error: expected ')' before '*' token
D:\devel\perl\perl\lib\CORE/perl.h:3544:45: error: expected ')' before '*' token
D:\devel\perl\perl\lib\CORE/perl.h:3544:45: error: expected ')' before '*' token
D:\devel\perl\perl\lib\CORE/perl.h:3544:29: error: expected ';' at end of member declaration
# define PERL_GET_THX ((PerlInterpreter *)PERL_GET_CONTEXT)
... and so on ...
Maybe somebody already solved similar problems?
This error occurs because <sstream>
happens to use setbuf
in an inline function, which one of the implicitly added headers (maybe XSUB.h
or perl.h
?) has redefined (using a preprocessor #define
).
This redefinition breaks loudly because it uses the PerlInterpreter
type, which is defined in a different namespace and not visible here (macros ignore namespaces, of course).
You can get the code to compile by adding
#undef setbuf
before including <sstream>
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With