On Wed, Jan 28, 2004 at 11:39:27AM -0800 unkno me wrote:

> --- Tassilo von Parseval
> <[EMAIL PROTECTED]> wrote:
> > On Mon, Jan 26, 2004 at 04:28:23PM -0800 unkno me
> > wrote:
> > 
> > > Hi,
> > > Does anyone how to set/unset warnings and strict
> > from
> > > XS? I want to enable or disable warnings and
> > strict
> > > depends on flag passed to my XS function.
> > 
> > For disabling strictures I would try mimicking what
> > strict.pm does:
> > 
> >     SV *mask = sv_get("^H", FALSE);
> >     SvIVX(mask) &= ~ 0x00000602;
> > 
> 
> I have not looked at strict.pm yet. I will take a
> look.

All it does is setting a bitmask in $^H. But I just realized how silly
the above it. It's a red herring. A better way would be:

    PL_hints |= HINT_STRICT_VARS;

would enable strict 'vars' and

    PL_hints &= ~HINT_STRICT_VARS;
    
would unset it again. perl.h also defines HINT_STRICT_REFS and
HINT_STRICT_SUBS.

> > I don't know whether this works. Also remember that
> > strict 'subs' and
> > 'vars' only have a compile-time effect.
> > 
> > As for warnings, I had this problem recently. I have
> > defined two macros:
> > 
> >     #define WARN_OFF \
> >         SV *oldwarn = PL_curcop->cop_warnings; \
> >         PL_curcop->cop_warnings = pWARN_NONE;
> > 
> >     #define WARN_RESTORE \
> >         PL_curcop->cop_warnings = oldwarn;
> > 
> 
> I think I tried that befor but it doesn't work. For
> some reason, the warning is not printed out. But I
> will give it another try and let you know how it goes.
> If it still doesn't work, I will post some code for
> inspection. Thanks!

The above code explicitly shuts up any warnings. pWARN_ALL would enable
all warnings. Maybe warnings.h will help you move around.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval

Reply via email to