On Sun, 18 Mar 2012, Sisyphus wrote: On Wed, 14 Mar 2012, "Mark Dootson" <mark.doot...@znix.com> wrote: >> Hi, >> >> On 11/03/2012 23:52, Sisyphus wrote: >> >>> An afterthought or two: It's a bug, right ? (It smells like a bug to >>> me.) Is it a bug in perl ? I'm thinking that CORE/win32.h should be >>> assigning the value associated with the actual OS on which perl is >>> running, rather than just assigning the minimum supported value.
Sorry for jumping into the thread late, but here are the reasons for how things are done the way they are (which by implication means I don't consider the current state to be a bug): CORE/win32.h does indeed define WINNNT, and it is being set to the lowest version of Windows still supported by that Perl version. Note that since Perl 5.12 the minimum Windows version is Windows 2000, so WINNT is now set to 0x0500 and CreateJobObjectA should be accessible without any problems. If you need to access newer APIs from C code, then the proper way to do this is to runtime-link to them using GetProcAddress. You can see an example in my implementation of the link() function for Perl when we still supported Windows NT (and Windows 95): http://perl5.git.perl.org/perl.git/commitdiff/6b980173#patch12 + BOOL (__stdcall *pfnCreateHardLinkW)(LPCWSTR,LPCWSTR,LPSECURITY_ATTRIBUTES); + WCHAR wOldName[MAX_PATH]; + WCHAR wNewName[MAX_PATH]; + + if (IsWin95()) + Perl_die(aTHX_ PL_no_func, "link"); + + pfnCreateHardLinkW = + (BOOL (__stdcall *)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES)) + GetProcAddress(GetModuleHandle("kernel32.dll"), "CreateHardLinkW"); + if (pfnCreateHardLinkW == NULL) + pfnCreateHardLinkW = Nt4CreateHardLinkW; On Windows 95 it will simply fail with an error message if you invoke the link() function, but otherwise the Perl is still loadable and functional. On Windows NT and later it tries to locate the CreateHardLinkW() API at runtime (and uses a backup internal implementation when it isn't available). This means a single Perl binary can be used on all supported Windows versions, and still have newer functionality available on the later versions. All this code got ripped out in Perl 5.12 when the minimum Windows version was raised to Windows 2000 and CreateHardLink() was now guaranteed to be available. If your own XS or Inline code doesn't want to do this (because the module doesn't provide any value at all if the newest APIs are not available), then you can just set WINNT at the top of your code before you include the Perl header files. win32.h will not redefine the symbol if it is already defined: #ifndef _WIN32_WINNT # define _WIN32_WINNT 0x0500 /* needed for CreateHardlink() etc. */ #endif Cheers, -Jan _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs