in reply to Re: Win32::API Memory Exception with GetCommandLine() (which returns a static string)
in thread Win32::API Memory Exception with GetCommandLine() (which returns a static string)

Thanks for the suggestion of "Inline::C". I hadn't seen that module before now. Unfortunately it's seems to be brittle on my system (failing because it didn't quote one of the Win32 directories with embedded spaces for gcc). However, it does produce a rough XS that I'll probably use quite a bit in the future.

I'll probably end up using XS. And so, I should thank you again for showing me the basic XS template for this function.

  • Comment on Re^2: Win32::API Memory Exception with GetCommandLine() (which returns a static string)

Replies are listed 'Best First'.
Re^3: Win32::API Memory Exception with GetCommandLine() (which returns a static string)
by syphilis (Archbishop) on Jul 08, 2007 at 10:10 UTC
    failing because it didn't quote one of the Win32 directories with embedded spaces for gcc

    Yes, there are problems with Inline::C and directory names that contain spaces. The problems are not insurmountable, but the best fix is to not install anything into a directory whose name contains any spaces.

    For the generation of the XS file and the Makefile.PL I just used InlineX::C2XS - ie, I placed a file named GetCommandLine.c (which contained just the solitary Inline::C function) in the ./src folder and ran
    perl -MInlineX::C2XS -e "InlineX::C2XS::c2xs('Win32::GetCommandLine',' +Win32::GetCommandline',{'WRITE_MAKEFILE_PL'=>1,'VERSION'=>0.01})"
    That creates the Makefile.PL and GetCommandLine.xs in the cwd. I then spent the next 15 minutes writing by hand GetCommandLine.pm (which I kept stuffing up) ... so I've now modified InlineX::C2XS::c2xs() to accept a 'WRITE_PM'=>1 argument that writes that .pm stub file as well. (This will be in the next CPAN release.)

    Note that there's more than one way to write an XS file (oO ... deja vu :-). The rendition that I posted is the way that Inline::C (which is used by InlineX::C2XS) autogenerated it.

    Cheers,
    Rob