Is it ok to define sv inside the curlies?

That shouldn't be of much concern portability-wise. Variable declarations at the beginning of a block (compound statement) have pretty much always been supported, at least since ANSI/ISO C (aka C89/C90), and - AFAIK - even before that time (i.e. old K&R-like variants).

As I wasn't entirely sure about definitions (as opposed to declarations), I tried the following snippet with the oldest compilers I could find (up to 12 years old) on various Unix platforms:

int main() { int x = 42; if (x==42) { int y = 99; x += y; } return 0; }

It did compile fine on all of them. Both in ANSI mode and when explicitly requesting the respective K&R emulation modes, i.e. cc -qlanglvl=classic (AIX), cc -Ac (HP-UX), cc -Xs (SunOS), cc -cckr (IRIX), gcc -traditional (Linux), etc. (note that -traditional is no longer supported with modern versions of gcc — I used a 10-year old gcc-2.95)

What isn't supported in strict ANSI C is mixing declarations/definitions and statements within the same block, such as

if (x==42) { x++; int y = 99; ... }

In reply to Re: Review of patch to avoid adding magic with rvalue $#a (XS gurus wanted) by almut
in thread Review of patch to avoid adding magic with rvalue $#a (XS gurus wanted) by ikegami

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.