Why there's such big difference? I cannot understand it...

(Yeah ... sorry, not much point running Inline::C scripts when we're dealing with something that's specific to Inline::CPP ;-)

I don't grok C++, and I can only assume that in your simplified Inline::CPP script, the write() call in ostream has not been made visible. It's definite that 'write' has been defined to 'PerlLIO_write' - just try to use write() in your Inline::CPP script and you'll be able to verify:
use strict; use Inline 'CPP' => config => BUILD_NOISY => 1; foobar(); use Inline 'CPP' => <<'CODE'; #include <perl.h> // not needed - gets included automatically #include <iostream> void foobar() { std::cout << "foobar" << std::endl; } void break_me(SV * a, SV * b) { write(a, b); } CODE
That generates the error:
try_pl_dec5.xs:28:14: error: macro "PerlLIO_write" requires 3 argument +s, but only 2 given write(a, b);
In ostream, the write() declaration is preceded (next line up) by __ostream_type&. I don't know whether that puts aome sort of condition upon whether the function is visible or not.
Maybe if you include the same headers in the compilation of your Inline::CPP script as were used for the C++ script then things might start to add up correctly.

I know it's messy ... XS is like that, but you just have to work through it.

Cheers,
Rob

In reply to Re^3: Name conflict between MinGW C++ standard library header and Perl development header by syphilis
in thread Name conflict between MinGW C++ standard library header and Perl development header by llancet

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.