Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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

by Anonymous Monk
on Aug 19, 2019 at 01:33 UTC ( #11104672=note: print w/replies, xml ) Need Help??

in reply to Defining an XS symbol in the Makefile.PL


$ ack MY_FORMAT * Goner2.c 170: printf(MY_FORMAT, sqrt(2.0)); Goner2.xs 14: printf(MY_FORMAT, sqrt(2.0)); Makefile 18:# DEFINE => q["-DMY_FORMAT=\"%.16e\""] 165:DEFINE = "-DMY_FORMAT=\"%.16e\"" 315: PASTHRU_DEFINE="\"-DMY_FORMAT=\\\"%.16e\\\"\" $(PASTHRU_DEFINE +)"\ Makefile.PL 26: DEFINE => q{"-DMY_FORMAT=\"%.16e\""}, $ perl -Mblib -MGoner2 -e" Goner2::beGone() " 1.4142135623730951e+000


$ perl -MExtUtils::MakeMaker - print MM->new->quote_literal('-DMY_FORMAT="%.16e"') __END__ Warning: Guessing NAME [Goner2] from current directory name. -DMY_FORMAT=\"%.16e\"



Replies are listed 'Best First'.
Re^2: Defining an XS symbol in the Makefile.PL (quoting)
by syphilis (Bishop) on Aug 19, 2019 at 06:14 UTC
    I don't quite follow, but I did try your suggestion of DEFINE => q{"-DMY_FORMAT=\"%.17\""} in the Makefile.PL.
    Note that I've altered the .16e to .17, as that's what's needed by the module I'm actually testing.
    That does allow the compilation to succeed and I do see this output during the build:
    gcc -c -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPTS + -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MIN +GW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -s -O2 -D +VERSION=\"1.52\" -DXS_VERSION=\"1.52\" "-IC:\_64\perl530_810\lib\COR +E" -DPERL_EXT -DUSE_PPPORT_H "-DMY_FORMAT=\"%.17\"" ListUtil.c
    which, I think, looks right.
    However, the XS code that relies on MY_FORMAT being set correctly still fails.
    I therefore stuck the following in the XS code to see exactly what MY_FORMAT looks like:
    printf("\n**%s**\n", MY_FORMAT);
    And that prints out **.17**, showing quite clearly that the quotes && the percentage sign have been lost.

    This Inline::C script also fails to build:
    use strict; use warnings; use Config; use Inline C => Config => USING => 'ParseRegExp', CCFLAGSEX => q["-DMY_FORMAT=\"%.16e\""], BUILD_NOISY => 1, ; use Inline C =><<'EOC'; SV * foo(void) { printf(MY_FORMAT, sqrt(2.0)); printf("\n"); } EOC foo();
    During the build I get:
    gcc -c -iquote"C:/_32/C" -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -DPER +L_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_ +PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bit +fields "-DMY_FORMAT=\"%.16e\"" -s -O2 -DVERSION=\"0.00\" -DXS_VERSI +ON=\"0.00\" "-IC:\_64\perl530_810\lib\CORE" try_pl_d937.c <command-line>: warning: missing terminating " character try_pl_d937.xs:1:10: fatal error: EXTERN.h: No such file or directory #include "EXTERN.h" ^~~~~~~~~~ compilation terminated.

    I am still quite open to testing other suggestions ... though I'm well and truly over trying to work it out for myself.

    Rob what did mycode show?
        Um ... what code ?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2019-09-17 00:16 GMT
Find Nodes?
    Voting Booth?
    The room is dark, and your next move is ...

    Results (199 votes). Check out past polls.