He just listed the 'clean' way.

Use the XS section for glue. Use the C section for implementation.

The XS section shouldn't be more than a few lines of C per subroutine.

I have hit this problem several times before, and have to the conclusion
that this _is_ the way to do it.

mark


On Sun, Sep 16, 2001 at 12:33:20PM -0700, "David Shultz" wrote:
> 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).  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?
> 
> 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 */
> 
> --
> Vivek

-- 
[EMAIL PROTECTED][EMAIL PROTECTED][EMAIL PROTECTED] __________________________
.  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | SIR Tools          (7H12)
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Nortel Networks
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, Ontario, Canada

  One ring to rule them all, one ring to find them, one ring to bring them all
                       and in the darkness bind them...

                           http://mark.mielke.cc/

Reply via email to