Last active
December 31, 2015 13:18
-
-
Save run4flat/7991591 to your computer and use it in GitHub Desktop.
Weird XSness fails to fail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ToTest; | |
use 5.008_008; | |
use strict; | |
use warnings; | |
our $VERSION = '0.01'; | |
require XSLoader; | |
XSLoader::load('ToTest', $VERSION); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "EXTERN.h" | |
#include "perl.h" | |
#include "XSUB.h" | |
#include "ppport.h" | |
MODULE = ToTest PACKAGE = ToTest | |
void | |
check_float_stuff(SV * constant_SV) | |
PROTOTYPE: $ | |
PREINIT: | |
float real_const, constant; | |
double constant_d; | |
CODE: | |
real_const = atof(SvPV_nolen(constant_SV)); | |
printf("The string interpretation of constant_SV is %s; the floating point is %f\n", | |
SvPV_nolen(constant_SV), SvNV_nomg(constant_SV)); | |
constant = (float) SvNV_nomg(constant_SV); | |
constant_d = SvNV_nomg(constant_SV); | |
printf(" -> when cast to a float, we have %f; to a double, %f\n", constant, constant_d); | |
printf(" -> when directly printed as %%f: %f\n", SvNV(constant_SV)); | |
printf(" -> real_constant is %f\n", real_const); | |
sv_dump(constant_SV); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use ToTest; | |
ToTest::check_float_stuff(5); | |
ToTest::check_float_stuff(0.25); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Perl v5.18.1, ExtUtils::nvcc as the compiler, Debian: