Steve Hay wrote:

>I was going to have it set the name of a debug variable which a (shared) 
>IsDebug() function would use:
>
>// Shared C code
>static char debug_var[64];
>static bool IsDebug(pTHX) {
>    return SvTRUE(get_sv(debug_var, FALSE));
>}
>
>// Shared XS code
>BOOT:
>{
>    strcpy(debug_var, SvPV_nolen(ST(0)));
>    strcat(debug_var, "::Debug");
>}
>
>so then XS code in Foo.xs and Bar.xs can each just say "if 
>(IsDebug(aTHX)) { ... }" without needing to tell IsDebug() which package 
>to lookup the $Debug variable in.
>
>It's not going to work, though, because it is possible (although 
>unlikely in this case) that a single program might use both modules, so 
>they'll be fighting over debug_var.
>
No, hang on.  I'm going mad now.  They won't be fighting over debug_var 
at all, because the "shared code" isn't shared at all by the time it's 
all been built.

It gets copied into each sub-dir's .xs/.c file, which are then built 
into two separate DLL's (or whatever), so they do have their own 
debug_var's.

Phew.

There's still a threading issue with static data, though, I realise.

- Steve



------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are 
confidential and intended for the addressee(s) only.  If you have received this 
message in error or there are any problems, please notify the sender immediately.  The 
unauthorized use, disclosure, copying or alteration of this message is strictly 
forbidden.  Note that any views or opinions presented in this email are solely those 
of the author and do not necessarily represent those of Radan Computational Ltd.  The 
recipient(s) of this message should check it and any attached files for viruses: Radan 
Computational will accept no liability for any damage caused by any virus transmitted 
by this email.

Reply via email to