Fixing an oversight in Math::Int64 A. Sinan Unur March 11, 2015

Ever since ETHER told me about it, I have been diligently using cpanm-reporter to report the results of running cpan-outdated | cpanm, and reporting any bugs I find.

Today's batch brought interesting failures in Math::Int64:

Int64.xs(79) : error C2061: syntax error : identifier 'nv2u64' Int64.xs(79) : error C2059: syntax error : ';' Int64.xs(79) : error C2059: syntax error : 'type' c:\...\work\1426111730.4692\math-int64-0.51\strtoint64.h(43) : error C2061: syntax error : identifier 'strtoint64' c:\...\work\1426111730.4692\math-int64-0.51\strtoint64.h(43) : error C2059: syntax error : ';' c:\...\work\1426111730.4692\math-int64-0.51\strtoint64.h(43) : error C2059: syntax error : 'type' c:\...\work\1426111730.4692\math-int64-0.51\isaac64.h(15) : error C2016: C requires that a struct or union has at least one member c:\...\work\1426111730.4692\math-int64-0.51\isaac64.h(15) : error C2061: syntax error : identifier 'uint64_t' c:\...\work\1426111730.4692\math-int64-0.51\isaac64.h(16) : error C2061: syntax error : identifier 'mm' c:\...\work\1426111730.4692\math-int64-0.51\isaac64.h(16) : error C2059: syntax error : ';' c:\...\work\1426111730.4692\math-int64-0.51\isaac64.h(16) : error C3409: empty attribute block is not allowed c:\...\work\1426111730.4692\math-int64-0.51\isaac64.h(16) : error C2143: syntax error : missing ']' before '(' c:\...\work\1426111730.4692\math-int64-0.51\isaac64.h(16) : error C2059: syntax error : 'constant' c:\...\work\1426111730.4692\math-int64-0.51\isaac64.h(17) : error C2061: syntax error : identifier 'aa' c:\...\work\1426111730.4692\math-int64-0.51\isaac64.h(17) : error C2059: syntax error : ';' c:\...\work\1426111730.4692\math-int64-0.51\isaac64.h(17) : error C2059: syntax error : ',' c:\...\work\1426111730.4692\math-int64-0.51\isaac64.h(18) : error C2059: syntax error : '}' ... [ snipped about 100 lines ]

At first sight, this looks crazy, and a little overwhelming. You can stare as much as you want at the reported locations, and you will not be able to see anything wrong.

No, the problem lies elsewhere.

The problem is right around line 27 in Int64.xs.

If you look up from that spot, you'll see that stdint.h is included if we are compiling with MinGW, but not if we are compiling with a Microsoft compiler.

There is a good reason for that: Visual Studio up to version 2010 did not include stdint.h .

But, I am building this with VS 2013, so things get messed up.

I just wanted to quietly fix this simple oversight, and issue a pull request.

Fork, clone, branch, perl Makefile.PL :

It looks like you're trying to build Math::Int64 from the git repo. You'll need to install Module::CAPIMaker from CPAN in order to do this.

OK. At least cpanm Module::CAPIMaker works. I have no idea what the module does. I haven't looked yet.

So, another perl Makefile and then nmake gives me:

C:\...\p5-Math-Int64> nmake Microsoft (R) Program Maintenance Utility Version 12.00.21005.1 Copyright (C) Microsoft Corporation. All rights reserved. cp lib/Math/UInt64.pm blib\lib\Math\UInt64.pm cp lib/Math/Int64/native_if_available.pm blib\lib\Math\Int64

ative_if_available.pm cp lib/Math/Int64.pm blib\lib\Math\Int64.pm cp lib/Math/Int64/die_on_overflow.pm blib\lib\Math\Int64\die_on_overflow.pm Running Mkbootstrap for Math::Int64 () "C:\opt\perl-5.20.2\bin\perl.exe" -MExtUtils::Command -e chmod -- 644 "Int64.bs" perl -MModule::CAPIMaker -emake_c_api module_name=Math::Int64 module_version=0.51 author='Salvador Fandino <[email protected]>, Dave Rolsky <[email protected]>' The system cannot find the file specified. NMAKE : fatal error U1077: 'perl' : return code '0x1' Stop.

Now, there are two bugs to fix.

Oh, at this point, I realize CAPIMaker stands for "C API Maker", not "CAPI Maker" as I had thought at first sight.

I spent quite some time staring at that, trying to figure out if I really had to dive into CAPIMaker.

Anyway, there is no need to create suspense. The cmd shell does not like single quotes. Instead, one must use:

My fix for the Makefile.PL bug is the simplest thing that solves the most immediate problem. If, in the future, authors with " marks in their names are added, it will have to be fixed.

With those two fixes, the module builds, and passes its tests on my system.

PS: test report and Pull request.

PPS: No comments for now, but you can discuss this post on /r/perl.

PPPS: It turns out I had missed the fact that Math::Int64 uses Config::AutoConf. The correct fix ended up being a bit more involved. Thank you Salvador.