![]() |
|
Problems? Is your data what you think it is? | |
PerlMonks |
Splitting an extension based on OSby syphilis (Archbishop) |
on Nov 06, 2007 at 10:51 UTC ( #649176=perlquestion: print w/replies, xml ) | Need Help?? |
syphilis has asked for the wisdom of the Perl Monks concerning the following question:
Hi, (Sorry ... couldn't think of a decent title.) Suppose I have a module (an extension) called G.pm. The source distro contains a very basic 'Makefile.PL', a 'G.pm' and a 'G.xs' (along with the usual supplementary files). The G.pm functions work differently, according to whether the operating system is Win32 or not - so there's a lot of checking to see whether $^O is 'MSWin32' or not. Similarly, in the XS file there's a need to #ifdef WIN32. It works fine .... but it might be cleaner if it was set up so that G.pm simply determined whether $^O was 'MSWin32', and then called either G/Win32.pm or G/Unix.pm (as appropriate). There's an example of splitting things up along these lines in (an old version of) the File::Spec distro - but it's pure perl ... and how to incorporate the XS element into such a split has me baffled. Questions that come to mind: Do I split the XS file into 2 separate files (one for Win32, one for Unix) as well ? If so, what do I call them and where do I place them ? Is there a CPAN distro that provides a good demo of how to achieve this when XS is involved ? The actual module in question is FileHandle::Fmode and I think it was suggested, quite some time ago, by dragonchild and/or BrowserUK that it be split along the lines that I've indicated here. (I've only just now got round to giving that serious consideration ... and sort of wish I hadn't :-) I had a bit of a speculative play around ... to the point where it became apparent that I should stop speculating, and start asking for a pointer or two. Cheers, Rob
Back to
Seekers of Perl Wisdom
|
|