Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Win32::api v0.75 issue importing DLL

by bulk88 (Priest)
on Mar 20, 2013 at 03:03 UTC ( #1024420=note: print w/replies, xml ) Need Help??

in reply to Win32::api v0.75 issue importing DLL

6. And optionally you can specify the calling convention, this defaults to '__stdcall', alternatively you can specify '_cdecl' or '__cdecl' (API > v0.68) or (API > v0.70_02) 'WINAPI', 'NTAPI', 'CALLBACK' (__stdcall), 'WINAPIV' (__cdecl) . False is __stdcall. Vararg functions are always cdecl. MS DLLs are typically stdcall. Non-MS DLLs are typically cdecl.

You didn't post any code, but I will assume what is happening from "No crash calling a function without any input parameter. ". Win32::API did less error checking against wrong C prototypes in the past. By chance, (actually depending on what version/build number of Visual C or Mingw/GCC the Win32::API XS DLL was compiled with_, certain severe prototype mistakes (wrong number of params or __stdcall vs __cdecl mistake) in the past worked silently (but the C function might have been passed uninitialized memory). Under the hood, a 32 bit function that takes NO parameters (it may or may not have a return value) meets the definition of being __stdcall and __cdecl at the same time, so that will "magically work". ActiveState uses Visual C 6 for all 32 bit XS modules available through AS PPM, if you compile it yourself with "MSVc++ express" (version number??), that is a different compiler. I think your 0.65 came from ActiveState, and your 0.75 was compiled with a 21st century Visual C. On 64 bit Windows, __stdcall and __cdecl in Win32::API have no effect, so you can mess those 2 up in 64 bit Perl, and it will "magically work". Of course 32 bit portable is then gone because it will crash.
  • Comment on Re: Win32::api v0.75 issue importing DLL

Replies are listed 'Best First'.
Re^2: Win32::api v0.75 issue importing DLL
by FabPerlExplorer (Initiate) on Mar 20, 2013 at 07:54 UTC
    Hi, I will check your suggestion. in the while below the codes. I'm not using the XS for time and effort reason (I have no experience with it). Then if it is possible I would like to use the win32api. the module code is the following:
    package Prova; #use strict; use warnings; # Import Win32::API and require version 0.64 use Win32::API 0.73; use Exporter; BEGIN { use Exporter (); our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); $VERSION = 1.00; @ISA = qw(Exporter); @EXPORT = qw( &dummyFunc &dummyFunc2 ); } BEGIN { $funcImportResult = Win32::API->Import('LibreriaDiProva', 'int dum +myFunc()'); $funcImportResult = Win32::API->Import('LibreriaDiProva', 'int dum +myFunc2(int a )'); } END{ } 1;
    while the perl script function is the following:
    #use lib qw(C:\UserData\JAZZ_FLOWS\DocToolForReport); use Prova; # To include Lessicum Client Universal interface wrapper $ciao = Prova::dummyFunc2(45); print $ciao;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024420]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2018-01-22 19:01 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (235 votes). Check out past polls.