c – Strawberry perl Inline :: CPP未编译
发布时间:2020-12-16 03:41:52 所属栏目:百科 来源:网络整理
导读:也许有人可以帮我理解.为什么会出现此错误. 我正在尝试构建使用Inline :: CPP的C代码. 这是一个例子: #!/usr/bin/env perlpackage main v0.1.0;use strict;use warnings;use Inline( CPP = 'CPP',#undef seekdir#include sstreamCPP # ccflags = '-std=c++1
也许有人可以帮我理解.为什么会出现此错误.
我正在尝试构建使用Inline :: CPP的C代码. 这是一个例子: #!/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__ 这段代码在linux下编译没有错误,但在草莓perl 5.26.2 x64下它会产生以下错误: "D:develperlperlbinperl.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:develperlperllibCORE" _2_pl_0f1f.c In file included from _2_pl_0f1f.xs:11:0: D:develperlperllibCORE/perl.h:3544:45: error: expected ')' before '*' token # define PERL_GET_THX ((PerlInterpreter *)PERL_GET_CONTEXT) ^ D:develperlperllibCORE/perl.h:3544:45: error: expected ')' before '*' token D:develperlperllibCORE/perl.h:3544:45: error: expected ')' before '*' token D:develperlperllibCORE/perl.h:3544:45: error: expected ')' before '*' token D:develperlperllibCORE/perl.h:3544:29: error: expected ';' at end of member declaration # define PERL_GET_THX ((PerlInterpreter *)PERL_GET_CONTEXT) ... and so on ... 也许有人已经解决了类似的问题? 解决方法
发生此错误是因为< sstream>碰巧在内联函数中使用了setbuf,其中一个隐式添加的头文件(可能是XSUB.h或perl.h?)已经重新定义(使用预处理器#define).
这种重新定义会大声破坏,因为它使用PerlInterpreter类型,该类型在不同的命名空间中定义,在此处不可见(当然,宏忽略命名空间). 您可以通过添加来编译代码 #undef setbuf 在包括< sstream>之前. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |