Because all that should be needed (on windows) is #define PERL_GET_CONTEXT TlsGetValue(PL_thr_key)
#define PERL_SET_CONTEXT(t) TlsSetValue(PL_thr_key, (t))
Quite why those calls are bracketed to preserve information from a previous error is strange.
What previous error have we ignored -- by continuing to this piece of code -- that we want to retain the extended error information for?
And what are we going to do with that retained information? And when?
You do realize your idea will break
$^E?
Remember there is this questionable file that can steal your C lib away from you,
win32/win32iop.h in perl.git.
errno is nearly useless on Windows since its so vague and rarely set compared to LastError/$^E. Side note, on a nytprof profiler in my experience, Win32::GetLastError() is 10 times faster than $^E. Perl does its best to always keep Win32's last error accurate to the last Win32 call you consciously made (CRT things, like malloc or free, or Kernel32 HeapAlloc (
http://msdn.microsoft.com/en-us/library/windows/desktop/aa366597%28v=vs.85%29.aspx), should not and do not change LastError), otherwise a mortal sweeping at scope boundaries would make LastError absolutely useless in perl as it frees SVPVs and make it impossible to do many Win32-ish things. Sometimes I've had GetLastError be screwed up in Perl because a
$obj = Win32::Foo->new("create me");
#new returned a blessed object
$obj = Win32::Foo->new("dont create me");
#new returned undef and LastError has failure code, DESTROY of "create
+ me" fires, changes LastError
if(! defined $obj){
#$^E happens to be ERROR_SUCCESS (it is actually undefined/random
+), programmer pounds head on keyboard screaming WHY ME!!!!
die "creating obj failed ".($^E+0);
}
IMHO, LastError is a terrible design. Native API's NTSTATUS error code system is much better thought out (
http://msdn.microsoft.com/en-us/library/cc231200%28v=prot.10%29) with positive signed numbers being informational non-errors, 0 being success with no information, and negative being errors.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.