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