Hi,

The following code builds and runs fine on linux (perl 5.8.8), but won't
compile on Win32 (perl 5.8.8):

use warnings;
use Inline C => Config =>
    BUILD_NOISY => 1;

use Inline C => <<'EOC';

#ifdef RUBBISH

void greet1() {
     printf("Hello 1\n");

//#else

//void greet1(){}

#endif

void greet2() {
     printf("Hello 2\n");
}

EOC

greet2();

__END__

'RUBBISH' is not defined on either box.

Here's the error I get on Win32:

try_pl_7b60.o(.text+0x7e):try_pl_7b60.c: undefined reference to `greet1'
collect2: ld returned 1 exit status
dmake:  Error code 129, while making
'blib\arch\auto\try_pl_7b60\try_pl_7b60.dll

If I want to get that to build on Win32 I have to include those 2 lines of C
code that are currently commented out.

This all translates to the real world situation where I have some XS code
that will run only on perl 5.8. So ... if the module is being built on perl
5.8, I define '-DPERL58' and have code like:

-------------------------
// the usual includes

#ifdef PERL58
void foo() {
      // do stuff
}
#endif
void bar() {
    // additional func that works on perl 5.8 or earlier
}
.
.
// Then the XS section - as per the type of XS file that Inline
auto-generates.
------------------

I was hoping that would build on perl 5.6 - and it does with linux, but not
with Win32 (where it produces the same type of error as above).

How best to proceed with this ?
Do I include an alternative dummy function that does nothing except cater
for the #else case ? That would seem rather comical to me.

Surely there's a better way of doing it.

Cheers,
Rob

Reply via email to