varargs float should (probably) be promoted to double
plicease opened this issue · 1 comments
plicease commented
✅ starscream% perl -MFFI::Platypus -E 'FFI::Platypus->new( lib => [undef] )->function( printf => ["string"] => ["double"] )->call("%f\n", 3.14 );'
3.140000
✅ starscream% perl -MFFI::Platypus -E 'FFI::Platypus->new( lib => [undef] )->function( printf => ["string"] => ["float"] )->call("%f\n", 3.14 );'
0.000000
example is on AMD64 Linux. The actual behavior is probably undefined.
Helpful reading from another project:
java-native-access/jna#463
alternatively using a float in a vararg could be an exception, but silently promoting it when the function is created shouldn't be too costly and probably safe users trying to do something that would automatically happen in C.
plicease commented
Note: there is some discussion on the libffi mainiling list as it if this should be handled at that level, and that would be fine, but since we support older versions of libffi it would be good to work around it in Platypus.