How to detect an undefined SV* value in XS?

T

Tassilo v. Parseval

Also sprach Sisyphus:
Another thread, and another list - and it has just been drawn to my
attention that's not the right way to assign PL_sv_undef to an SV. The
above line should be replaced by:

a = &PL_sv_undef

Wont help either. You cannot change 'a' in-place thusly. If you want
that you'd have to have something like:

void set_undef (SV **a) {
*a = &PL_sv_undef;
}

But I don't think that Inline::C or XS know about an SV** prototype. The
reason is again the difference between changing a C-structure internally
(this is what sv_setsv does) or having a variable point to something
else. If you want to do the latter, you need to pass the pointer by
reference. These are the usual C-semantics.
I haven't tested, but I expect one would then find that the script
reports "A valid means of testing for &PL_sv_undef".

Only if the variable passed to set_undef() was a real PL_sv_undef in the
first place. :) What you are thinking of is a no-op.

Tassilo
 
S

Sisyphus

Tassilo said:
Also sprach Sisyphus:




Wont help either. You cannot change 'a' in-place thusly. If you want
that you'd have to have something like:

void set_undef (SV **a) {
*a = &PL_sv_undef;
}

But I don't think that Inline::C or XS know about an SV** prototype. The
reason is again the difference between changing a C-structure internally
(this is what sv_setsv does) or having a variable point to something
else. If you want to do the latter, you need to pass the pointer by
reference. These are the usual C-semantics.




Only if the variable passed to set_undef() was a real PL_sv_undef in the
first place. :) What you are thinking of is a no-op.

Tassilo

A tree ... and some rope .... that's all I *really* need ;-)

Cheers,
Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top