Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^7: Defining an XS symbol in the Makefile.PL (quoting)

by jcb (Chaplain)
on Aug 19, 2019 at 22:45 UTC ( #11104706=note: print w/replies, xml ) Need Help??


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 (Bishop) 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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11104706]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2019-10-20 08:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?