Sun May 20 10:04:43 2012: Request 36186 was acted upon. Transaction: Correspondence added by bulk88. Queue: Win32-API Subject: Win32_API-0.55 can't handle doubles Broken in: 0.55 Severity: Important Owner: COSIMO Requestors: sisyp...@cpan.org Status: open Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=36186 >
On Mon May 26 07:53:40 2008, SISYPHUS wrote: > This is using Win32-API-0.55, Visual Studio 7.0, and perl 5.10.0 (built > from source using the same Visual Studio 7.0 compiler) > > --- mydll.h ---- > __declspec(dllexport) int my_int(int); > > __declspec(dllexport) double my_double(int); > > ---------------- > > --- mydll.c ---- > #include "mydll.h" > > __declspec(dllexport) int my_int(int x) { > return x / 7; > } > > __declspec(dllexport) double my_double(int x) { > return (double) x / 7; > } > > ---------------- > > Build the dll: > > ---------------- > C:\_32\c>cl /LD mydll.c > Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.00.9466 for > 80x86 > Copyright (C) Microsoft Corporation 1984-2001. All rights reserved. > > mydll.c > Microsoft (R) Incremental Linker Version 7.00.9466 > Copyright (C) Microsoft Corporation. All rights reserved. > > /out:mydll.dll > /dll > /implib:mydll.lib > mydll.obj > Creating library mydll.lib and object mydll.exp > > C:\_32\c> > ---------------- > > The perl script that attempts to access mydll.dll using Win32-API-0.55: > > --- mydll.pl --- > use Win32::API; > use warnings; > > $func1 = new Win32::API('mydll', 'my_int', 'N', 'N', '_cdecl'); > $val = $func1->Call(123); > > print "Val1: $val\n"; > > $func2 = new Win32::API('mydll', 'my_double', 'N', 'D', '_cdecl'); > $val = $func2->Call(123); > > print "Val2: $val\n"; > > ---------------- > > Run mydll.pl: > > ---------------- > C:\_32\c>perl mydll.pl > Val1: 17 > Use of uninitialized value $val in concatenation (.) or string at > mydll.pl line 12. > Val2: > > C:\_32\c> > ---------------- > > Clearly the reported value for $val1 is correct, but not for $val2. > > Cheers, > Rob I can't reproduce this on Win32::API 0.68. I guess its been fixed by now.