Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by Anonymous Monk
on Aug 19, 2019 at 09:15 UTC ( [id://11104682]=note: print w/replies, xml ) Need Help??


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

Heh, whats going on?

#!/usr/bin/perl -- use strict; use warnings; use Config; use Inline C => Config => USING => 'ParseRegExp', CCFLAGSEX => q["-DMY_FORMAT=\"%.17e\""], BUILD_NOISY => 1, CLEAN_AFTER_BUILD => 0, ; use Inline C =><<'EOC'; void* foo(void) { printf("***%s***\n", MY_FORMAT); printf(MY_FORMAT, sqrt(2.0)); printf("\n%.17e\n", sqrt(2.0)); } EOC foo(); __END__ $ perl inline-eumm-define-sprintf-11104628.pl validate Stage Starting Build Preprocess Stage get_maps Stage Finished Build Preprocess Stage Starting Build Parse Stage Finished Build Parse Stage Starting Build Glue 1 Stage Finished Build Glue 1 Stage Starting Build Glue 2 Stage Finished Build Glue 2 Stage Starting Build Glue 3 Stage Finished Build Glue 3 Stage Starting Build Compile Stage Starting "perl Makefile.PL" Stage Generating a dmake-style Makefile Writing Makefile for inline_eumm_define_sprintf_11104628_pl_5316 Writing MYMETA.yml and MYMETA.json Finished "perl Makefile.PL" Stage Starting "make" Stage Running Mkbootstrap for inline_eumm_define_sprintf_11104628_pl_5316 () "D:\perl\bin\perl.exe" -MExtUtils::Command -e chmod -- 644 "inline_eum +m_define_sprintf_11104628_pl_5316.bs" "D:\perl\bin\perl.exe" -MExtUtils::Command::MM -e cp_nonempty -- inlin +e_eumm_define_sprintf_11104628_pl_5316. bs blib\arch\auto\inline_eumm_define_sprintf_11104628_pl_5316\inline_e +umm_define_sprintf_11104628_pl_5316.bs 644 "D:\perl\bin\perl.exe" "D:\perl\site\lib\ExtUtils\xsubpp" -typemap "D +:\perl\lib\ExtUti ls\typemap" inline_eumm_define_sprintf_11104628_pl_5316.xs > inline_e +umm_define_sprintf_11104628_pl_5316.xsc "D:\perl\bin\perl.exe" -MExtUtils::Command -e mv -- inline_eumm_define +_sprintf_11104628_pl_5316.xsc inline_eu mm_define_sprintf_11104628_pl_5316.c gcc -c -s -O2 -DWIN32 -DPERL_RELOCATABLE_INCPUSH -DPERL_TEX +TMODE_SCRIPTS -DUSE_SITECUSTOMIZE - DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -mms-b +itfields -D_USE_32BIT_TIME_T "-DMY_FORMAT=\"%.17e\ "" -s -O2 -DVERSION=\"0.00\" -DXS_VERSION=\"0.00\" "-ID:\p +erl\lib\CORE" inline_eumm_define_spri ntf_11104628_pl_5316.c "D:\perl\bin\perl.exe" -MExtUtils::Mksymlists \ -e "Mksymlists('NAME'=>\"inline_eumm_define_sprintf_11104628_pl_5 +316\", 'DLBASE' => 'inline_eumm_define_sprintf_111 04628_pl_5316', 'DL_FUNCS' => { }, 'FUNCLIST' => [], 'IMPORTS' => { +}, 'DL_VARS' => []);" g++ inline_eumm_define_sprintf_11104628_pl_5316.def -o blib\arch\auto\ +inline_eumm_define_sprintf_11104628_pl_5316\inline _eumm_define_sprintf_11104628_pl_5316.dll -mdll -D_USE_32BIT_TIME_T -s + -L"D:\perl\lib\CORE" -L"D:\perl\mingw\mingw32\i686-w64-mingw32\lib" +inline_eumm_define_sprintf_11104628_pl_5316.o "D:\perl\lib\CORE\li bperl516.a" -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg +32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetap i32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomc +tl32 -Wl,--enable-auto-image-base "D:\perl\bin\perl.exe" -MExtUtils::Command -e chmod -- 755 blib\arch\a +uto\inline_eumm_define_sprintf_11104628 _pl_5316\inline_eumm_define_sprintf_11104628_pl_5316.dll Finished "make" Stage Starting "make install" Stage "D:\perl\bin\perl.exe" -MExtUtils::Command::MM -e cp_nonempty -- inlin +e_eumm_define_sprintf_11104628_pl_5316. bs blib\arch\auto\inline_eumm_define_sprintf_11104628_pl_5316\inline_e +umm_define_sprintf_11104628_pl_5316.bs 644 Files found in blib\arch: installing files in blib\lib into architectu +re dependent library tree Installing _Inline\lib\auto\inline_eumm_define_sprintf_11104628_pl_531 +6\inline_eumm_define_sprintf_11104628_ pl_5316.dll Finished "make install" Stage Starting Cleaning Up Stage Finished Cleaning Up Stage Finished Build Compile Stage ***%.17e*** 1.41421356237309510e+000 1.41421356237309510e+000

Replies are listed 'Best First'.
Re^6: Defining an XS symbol in the Makefile.PL (quoting)
by syphilis (Archbishop) on Aug 19, 2019 at 12:05 UTC
    Heh, whats going on?

    Good question ... I don't have an answer to that ;-)

    Your code still results in the same error for me: fatal error: EXTERN.h: No such file or directory.
    Looks like the "-iquote" that my Inline-C-0.81 invokes is stuffing things up.

    UPDATE: No, it has nothing to do with "-iquote". Turns out that when I switched to I-C-0.76 I also switched to EU-MM-7.04, and the problem I'm facing is due solely to a change that occurs in EU::MM some time between 7.0401 (which is fine) and 7.1001 (which breaks Inline::C). I'll investigate further when I get a chance and file a bug report if warranted.

    What version of Inline::C are you running ? When I switch to Inline-C-0.76, your script works fine - as does mine if I replace the incorrect SV * foo(... with void foo(....

    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 ?
    Can you explain that ?

    BTW, seems that my problem with finding a correct rendition for the DEFINE in the Makefile.PL is dependent upon the version of EU::MM.
    With EU-MM-7.04, this is fine:
    DEFINE => q["-DMY_FORMAT=\\"%.17\\""];
    But with EU-MM-7.34 (which is what I've been using) the crucial percentage symbol is still being omitted.

    Cheers,
    Rob
      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.

        ..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
      Inline 0.80 Inline::C 0.76 ExtUtils::MakeMaker 7.20

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-03-28 22:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found