On Sun, 16 Sep 2001, David Shultz wrote:

>       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
[cut]
> into either XS or the c code (but with function defs..) I don't see any
> clean way around this.  Any ideas?

The cleanest way, imo, is to keep the XS code to a minimum, and put your
functions in a separate .c file: The files mentioned below are in a separate 
directory in my source tree, called 'internals', and get compiled into 
libfoointernals.so, which Foo.so uses. The C code can have 

#ifdef PLATFORM       
#endif /*PLATFORM */

and so on in it, as required.

> 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
> 
> 

Reply via email to