develooper Front page | perl.perl5.porters | Postings from June 2012

Re: Time for a 64-bit perl API?

Thread Previous | Thread Next
From:
Reverend Chip
Date:
June 19, 2012 13:34
Subject:
Re: Time for a 64-bit perl API?
Message ID:
4FE0E258.3020104@gmail.com
On 6/19/2012 1:26 PM, Jan Dubois wrote:
> On Tue, 19 Jun 2012, bulk 88 wrote:
>> ----------------------------------------
>> On Mon, 18 Jun 2012, rev.chip@gmail.com wrote:
>>> On 6/18/2012 9:46 AM, bulk 88 wrote:
>>>> A problem I've run into in the past is ((__int64)-1) == ((int)-1) is false.
>>> Well, that's not true. So I think you do not understand the situation.
>>>
>>>
>> _________________________________________
>> #include "EXTERN.h"
>> #include "perl.h"
>> #include "XSUB.h"
>>
>> #include "ppport.h"
>>
>> #define ERRORFLAG (-1)
>>
>> void my_cmp(pTHX_ size_t num){
>>     size_t num2 = ERRORFLAG;
>>     if(num != num2)
>>        croak("not equal");
>> }
>>
>>
>> MODULE = Local::XS        PACKAGE = Local::XS
>>
>> void
>> neg1()
>> PREINIT:
>>     unsigned int num;
> You are using (unsigned int) here, which is not the same as (int).

Indeed.  An error value for an unsigned type, in a properly portable
program like Perl, would be ~(type)0 or (type)-1, not bare -1.



>
>> PPCODE:
>>     num = ERRORFLAG;
>>     my_cmp(aTHX_ num);
>> ________________________________________
>> #!/usr/bin/perl -w
>> use strict;
>> use Local::XS;
>> Local::XS::neg1();
>> ________________________________________
>> not equal at n1.pl line 4.
> Does it also print "not equal" when you remove the "unsigned"?
>
> Cheers,
> -Jan
>
>



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About