Nick,
I'm starting to think supporting multiple cdroms on *nix systems is
probably a good idea anyway so maybe I can simply support either drive
letters and/or dev/device listing... or even an auto search system, but
either way I go thanks for the info (to all who has responded) since #ifdefs
in xs code is something I run into often enough to appreciate the answers
I've gotten.
David S.
-----Original Message-----
From: Nick Ing-Simmons [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 17, 2001 12:05 AM
To: [EMAIL PROTECTED]
Cc: Vivek Dasmohapatra; [EMAIL PROTECTED]
Subject: RE: ifdefs in xs?
David Shultz <[EMAIL PROTECTED]> writes:
>Yeah,
>
> What I'm doing is calling different funcs depending on OS (*nix and/or
>win32) dealing with devices (cdroms). So the linux version calls with one
>less param (no dev/drive) vs. the windows version needs to know what drive
>(incase multiple cd drives exist).
My linux machines have muliple CDROMS...
>I'm currently doing this before calling
>the xs code but would like to find a way to move this outta the perl code
>into either XS or the c code (but with function defs..) I don't see any
>clean way around this. Any ideas?
Anyway IIRC it can be done - in places - e.g. the body of a CODE: can
have #ifdefs - but not blank lines.
I would be tempted to make the XS code take optional (or defaulted) arg
and do as other suggest and handle differences in C parts - or as you
already are in the perl parts.
>
>David S.
>
>-----Original Message-----
>From: Vivek Dasmohapatra [mailto:[EMAIL PROTECTED]]
>Sent: Sunday, September 16, 2001 5:08 AM
>To: David Shultz
>Cc: [EMAIL PROTECTED]
>Subject: Re: ifdefs in xs?
>
>
>On Sat, 15 Sep 2001, David Shultz wrote:
>
>> Does anyone know if/how you can do ifdefs in xs?
>
>In the C section of the XS file [ie before the MODULE tag] you are writing
>C, with some magic perl headers pulled in by the build system - you can put
>ifdefs there. Also, I like to keep my XS declarations relatively small,
>and put the bulk of the function in a separate .c file, eg my XS
declaration
>might say just:
>
>int
>_cancel_order (ARG, flags)
> SV * ARG
> int flags
>
>And then I have separate cancel.c and cancel.h files which contain things
>like:
>
>int _cancel_order (SV *X, int flags)
>{
> int retval;
> CLIENT *client;
> .
> .
> .
>
>and [in the .h file]:
>
>#ifndef FOO_CANCEL_H
>#define FOO_CANCEL_H
>
>#include "foo_internals.h"
>
>extern int _cancel_order (SV *X, int flags);
>
>#endif /* FOO_CANCEL_H */
--
Nick Ing-Simmons
http://www.ni-s.u-net.com/