zdm has asked for the wisdom of the Perl Monks concerning the following question:

Hey, maybe somebody can help me to understand. why this error occurs. I am trying to build C++ code, that use <sstream> 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\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?

Replies are listed 'Best First'.
Re: strawberry perl + Inline::CPP + <sstream> compilation error
by syphilis (Archbishop) on Jun 04, 2018 at 00:49 UTC
    Maybe somebody already solved similar problems?

    Or maybe not ?
    The failing script can be reduced to:
    use strict; use warnings; use Inline CPP => <<'CPP'; #include <sstream> CPP 1;
    which (I think) still produces the same errors.

    This would suggest that there's some fundamental incompatibility between perl.h and the sstream header with mingw-w64 compilers.
    But it's not clear to me just what that incompatibility is. (We might need someone with some C++ insights to chime in.)

    Do you really need to include sstream ?

    UPDATE: For those interested, the original post has been cross-posted to stackoverflow.

    Cheers,
    Rob
      <sstream> is used by dlib (dlib.net). I am using dlib in my project.
        <sstream> is used by dlib (dlib.net). I am using dlib in my project

        I guess that means you'll need sstream ;-)

        There's a reply on stackoverflow that indicates that the problem is that one of the standard perl headers defines "setbuf".
        I find that the following compiles ok for me:
        use strict; use warnings; use Inline CPP => <<'CPP'; #undef seekdir #ifdef _WIN32 #undef setbuf #endif #include <sstream> CPP 1;
        So see how that works for you.

        Cheers,
        Rob
Re: strawberry perl + Inline::CPP + <sstream> compilation error
by Anonymous Monk on Jun 03, 2018 at 22:02 UTC
    what compiler?
      gcc 7.1 x64