in reply to Inline::C Needed for Win32, Want it Off For UNIX
You already have a good answer but I thought I'd add on and tell you why your Win32 syntax didn't work. Its broken as-is. The use Inline C statement is executed during BEGIN-time regardless of whether the if() condition is true or not. That is, use() does a require() and import() during the compilation time and isn't affected at all about what happens later when the if() executes.
Actual results
use Inline C => DATA => NAME => 'inline_code_pl_2d59'; if ( $^O eq 'MSWin32' ) { # Do nothing }
What you could have written that would have worked on both unix and Win32.
BEGIN { if ( $^O eq 'MSWin32' ) { # Option A require Inline; Inline->import( C => DATA => NAME => 'inline_code_pl_2d59' ); # Option B eval "use Inline C => DATA => NAME => 'inline_code_pl_2d59'"; die $@ if $@; # Option B with line numbers that make sense if die() happens eval "#line " . ( 1 + __LINE __ ) . " \"" . __FILE __ . "\"\n" . "use Inline C => DATA => NAME => 'inline_code_pl_2d59' +"; die $@ if $@; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Inline::C Needed for Win32, Want it Off For UNIX
by Kapper_Coder (Initiate) on Oct 28, 2005 at 20:37 UTC | |
by diotalevi (Canon) on Oct 28, 2005 at 20:39 UTC | |
by ikegami (Patriarch) on Oct 28, 2005 at 21:24 UTC |