Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INVALID_HANDLE_VALUE has the 32-bit value even in 64-bit builds #13

Open
nmisch opened this issue Jul 18, 2022 · 0 comments
Open

INVALID_HANDLE_VALUE has the 32-bit value even in 64-bit builds #13

nmisch opened this issue Jul 18, 2022 · 0 comments

Comments

@nmisch
Copy link

nmisch commented Jul 18, 2022

Program:

use Win32API::File ();
close STDIN;
printf("INVALID_HANDLE_VALUE = 0x%x\nFdGetOsFHandle = 0x%x\n",
       Win32API::File::INVALID_HANDLE_VALUE,
       Win32API::File::FdGetOsFHandle(0));

I expected the two handle values to be equal, since the FdGetOsFHandle pod
documentation says, on failure, "C<$hNativeHandle> is set to
C<INVALID_HANDLE_VALUE>". In strawberry-perl-5.32.1.1-64bit, the handles
are unequal. Program output:

INVALID_HANDLE_VALUE = 0xffffffff
FdGetOsFHandle = 0xffffffffffffffff

Equivalently, one can see this in a TAP test by adding t/closed.t with the
following content:

use Test::More;
use Win32API::File ();
plan tests => 1;
close STDIN;
is(Win32API::File::INVALID_HANDLE_VALUE, Win32API::File::FdGetOsFHandle(0));

I get this behavior with the preinstalled module and also when building
https://github.com/chorny/Win32API-File in the
strawberry-perl-5.32.1.1-64bit environment.
Win32API::File::INVALID_HANDLE_VALUE is the value that C-level
INVALID_HANDLE_VALUE would have in a 32-bit binary, despite this being a
64-bit Perl.

The distribution has code, disabled by default, for regenerating the constants
(search for Myconst2perl and NO_REBUILD). Enabling that code yields one
error and a flurry of warnings:

...
const2perl.h:119:19: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
  newconst( sName, "%"IVdf, iValue, newSViv(iValue) );
                   ^
const2perl.h:122:19: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
  newconst( sName, "%"IVdf, iValue, newSViv(iValue) );
                   ^
const2perl.h:133:19: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
  newconst( sName, "0x%"UVxf, (UV)(pValue), mpSvNew );
                   ^
const2perl.h:99:5: error: extra qualification '_const2perl::' on member '_const2perl' [-fpermissive]
     _const2perl::_const2perl( char *sModName ) {
     ^~~~~~~~~~~
File.xs: In function 'int main(int, char**, char**)':
const2perl.h:143:63: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 #define START_CONSTS( sModName ) _const2perl const2( sModName );
                                                               ^
File.xs:28:5: note: in expansion of macro 'START_CONSTS'
 #if (PERL_REVISION <= 5 && PERL_VERSION < 5) || defined(__CYGWIN__)
     ^~~~~~~~~~~~
const2perl.h:144:60: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 #define const2perl( const )  const2.mkconst( #const, const )
                                                            ^
File.xs:40:5: note: in expansion of macro 'const2perl'
 #  undef _open_osfhandle /* stolen_open_osfhandle() isn't available here */
     ^~~~~~~~~~
const2perl.h:144:60: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 #define const2perl( const )  const2.mkconst( #const, const )
                                                            ^
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant