Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: PerlIO::Layers 0.011 fails to build in macOS 10.13.3

by syphilis (Archbishop)
on Mar 27, 2018 at 01:28 UTC ( [id://1211811]=note: print w/replies, xml ) Need Help??


in reply to Re: PerlIO::Layers 0.011 fails to build in macOS 10.13.3
in thread PerlIO::Layers 0.011 fails to build in macOS 10.13.3

The problem is when macro ... is passed a non-literal string

Good catch.
I had seen the comments in handy.h, and noted the absence of quotes in perlboy_emeritus' build - but still failed to put it all together properly.
(I had myself thinking that the strange ("" s "") construct must have been magically enforcing the requisite stringification but, of course, it merely throws the error if s is not a string.)

So the bug is in the version of Module::Build that perlboy_emeritus has installed - and any perl extension that is built with ExtUtils::MakeMaker (instead of Module::Build) will be free from this issue.
The version of Module::Build that I was using (on Windows) is 0.4214, which was fine - so I guess another alternative might have been to simply update Module::Build to a later version.

Here's a little C demo that I ran just to satisfy my limited understanding:
C:\_32\C>type try.c #include <stdio.h> int main (void) { #define FOO(s) printf("%s\n", "" s ""); FOO(VER); return 0; } C:\_32\C>gcc -o try.exe -DVER="\"0.1\"" try.c C:\_32\C>try 0.1 C:\_32\C>gcc -o try.exe -DVER=0.1 try.c try.c: In function 'main': try.c:5:2: error: expected ')' before numeric constant
Cheers,
Rob

Replies are listed 'Best First'.
Re^3: PerlIO::Layers 0.011 fails to build in macOS 10.13.3
by bliako (Monsignor) on Mar 28, 2018 at 21:35 UTC

    with your little c-program:

    gcc -DVER="0.1" -E try.c

    does the preprocessor pass and expands FOO to:

    printf("%s\n", "" 0.1 "")

    and

    gcc -DVER="\"0.1\"" -E try.c

    expands it to:

    printf("%s\n", "" "0.1" "")

    so, whereas

    printf("%s\n", 0.1)

    would have caused just a warning at compile time and a crash later,

    printf("%s\n", "" 0.1 "")

    causes an error right away

    and
    printf("%s\n", "" "0.1" "")

    is legitimate.

    bliako
      printf("%s\n", "" "0.1" "") didn't immediately look like valid C to me (and it's not valid perl).
      But C does allow that type of concatenation - whereas I guess perl doesn't really need to.
      Even in assignment one can do char *x = "hello" "0.01" "world";

      Cheers,
      Rob

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-24 07:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found