in reply to Re^6: Defining an XS symbol in the Makefile.PL (quoting)
in thread Defining an XS symbol in the Makefile.PL

But now I'm puzzled as to the output we get for printf("***%s***\n", MY_FORMAT); The quotes either side of %.17e are apparently missing from MY_FORMAT. So how does printf(MY_FORMAT, sqrt(2.0)) even compile ?

C syntax and preprocessing rules. MY_FORMAT is substituted by the C preprocessor, so the compiler sees printf("***%s***\n", "%.17e");, strips the quotes off of the string constant like any other, and the output is ***%.17e*** if everything works correctly. The % character is also special in the DOS shell, which uses it for variable substitution: %PATH% on DOS is $PATH on *nix. The trailing % is required, but I would not be surprised if bugs in the shell like to eat random % characters.

You will be much better off passing a number instead of a string constant if you want this to compile on Windows.

Replies are listed 'Best First'.
Re^8: Defining an XS symbol in the Makefile.PL (quoting)
by syphilis (Archbishop) on Aug 20, 2019 at 00:59 UTC
    ..so the compiler sees printf("***%s***\n", "%.17e");, strips the quotes off of the string constant like any other ...

    Oh yes, of course. Silly me.
    Thanks !

    Cheers,
    Rob