syphilis has asked for the wisdom of the Perl Monks concerning the following question:
I want to rewrite that line as:printf("%.16e", sqrt(2.0));
I also wish to then define MY_FORMAT to "%.16e" in the Makefile.PL.printf(MY_FORMAT, sqrt(2.0));
But that specific incantation fails to work - and I haven't been able to hit on the incantation that *does* work.WRITEMAKEFILE( .... DEFINE => '-DMY_FORMAT="%.16e"', .... );
I've tried various escapes around "%.16e" but nothing has been successful.use strict; use warnings; use Config; use Inline C => Config => USING => 'ParseRegExp', CCFLAGSEX => '-DMY_FORMAT="%.16e"', BUILD_NOISY => 1, ; use Inline C =><<'EOC'; SV * foo(void) { printf(MY_FORMAT, sqrt(2.0)); printf("\n"); } EOC foo();
I'm not all that bothered if it turns out that Inline::C can't handle the construct, but I *would* like to know how to do it in the XS file via the Makefile.PL if, indeed, that's possible at all.C:\_32\C>type try.c #include <stdio.h> #include <math.h> int main(void) { printf(MY_FORMAT, sqrt(2.0)); return 0; } C:\_32\C>gcc -o try.exe try.c -DMY_FORMAT=\"%.16e\" C:\_32\C>try 1.4142135623730951e+000 C:\_32\C>
|
|---|