Hi,
I have an issue with the Microsoft compiler (cl) toolchain, in relation only to those perls whose $Config{ivsize} and $Config{nvsize} are both 8.
Note that such a perl configuration is very common.
The demo:
use strict;
use Config;
use Devel::Peek;
die "This configuration of perl not relevant to the issue"
unless $Config{nvsize} == $Config{ivsize};
use Inline C => Config =>
PRE_HEAD => "#ifndef __USE_MINGW_ANSI_STDIO\n#define __USE_MINGW_ANS
+I_STDIO 1\n#endif\n",
;
use Inline C => <<'EOC';
void foo(SV * in) {
printf("%.20" NVgf, SvNV(in));
printf("\n");
}
EOC
# Create an NV whose value is
# 18446744073709549568
my $nv = ((1 << 53) - 1) / 2 * 4096;
# Dump $nv; # Shows that it's an NV.
foo($nv);
foo(18446744073709549568);
The desired output (which I see on Linux and mingw-built windows perls) is:
18446744073709549568
18446744073709549568
My only perl built using a Microsoft compiler (5.16.0 using cl 14.00.40310.41) doesn't play ball, and outputs:
18446744073709550000
18446744073709550000
How do I get the output I want with this cl-built perl ?
Do more modern versions of the MS toolchain enable me to get my desired output ?
Any solution that involves changing the final argument that printf() takes (ie
SvNV(in)) is probably not a satisfactory one.
But if there's some symbol that can be defined, or some alteration to the formatting spec, then that would be great.
BTW, the script only works as desired with mingw-built perls because it defines __USE_MINGW_ANSI_STDIO to a true value if perl has not already defined it.
Without that definition, mingw-built perls display the same output as my cl-built perl-5.16.0.
I believe the problem with the cl-built perl is a toolchain issue, not a perl one.
Cheers,
Rob
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.