Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Using Win32::API (version 0.41) I define a fuction that returns a void value in a DLL as follows:
Win32::API->Import( 'mbrola', 'void reset_MBR()' ) || print STDERR "Failed Import:\n$^E\n";
and recieved the error
Win32::API::parse_prototype: WARNING unknown output parameter type 'void' at C:/Perl/site/lib/Win32/API.pm line 273, <DATA> line 164.
What's the problem (other than the fact that I am using windoze)?

Replies are listed 'Best First'.
Re: void is an unknown type
by hossman (Prior) on Feb 09, 2004 at 19:39 UTC

    I've never used Win32::API, but I just took a quick glance at teh perldocs for the Import method, followed the link to Win32::API::Type and then read the part that says...

    SUPPORTED TYPES
    This module should recognize all the types defined in the Win32 Platform SDK header files. Please see the source for this module, in the __DATA__ section, for the full list.

    ...so i clicked the "Source" link, scrolled down, and saw that it listed "VOID" as a valid type.

    Which makes me wonder if this would work...

    Win32::API->Import( 'mbrola', 'VOID reset_MBR()' ) || print STDERR "Failed Import:\n$^E\n";
Re: void is an unknown type
by Mr. Muskrat (Canon) on Feb 10, 2004 at 00:11 UTC
    IIRC, Win32::API's Import method is still a bit buggy. Last I heard, dada was working on a new version that should fix it. Until then, you might have better luck using one of the other two methods.
Re: void is an unknown type
by Anonymous Monk on Feb 10, 2004 at 19:26 UTC
    Hello, If you add a function in Win32::API::Type as follows:
    sub myinit { if ($Known{ATOM} eq "") { print "ATOM: " . $Known{ATOM} . "\n"; my $section = 'nothing'; foreach (<DATA>) { next if /^\s*#/ or /^\s*$/; chomp; if( /\[(.+)\]/) { $section = $1; next; } if($section eq 'TYPE') { my($name, $packing) = split(/\s+/); # DEBUG "(PM)Type::INIT: Known('$name') => '$packing'\ +n"; $Known{$name} = $packing; } elsif($section eq 'PACKSIZE') { my($packing, $size) = split(/\s+/); # DEBUG "(PM)Type::INIT: PackSize('$packing') => '$siz +e'\n"; $PackSize{$packing} = $size; } elsif($section eq 'MODIFIER') { my($modifier, $mapto) = split(/\s+/, $_, 2); my %maps = (); foreach my $item (split(/\s+/, $mapto)) { my($k, $v) = split(/=/, $item); $maps{$k} = $v; } # DEBUG "(PM)Type::INIT: Modifier('$modifier') => '%ma +ps'\n"; $Modifier{$modifier} = { %maps }; } elsif($section eq 'POINTER') { my($pointer, $pointto) = split(/\s+/); # DEBUG "(PM)Type::INIT: Pointer('$pointer') => '$poin +tto'\n"; $Pointer{$pointer} = $pointto; } } } }

    Then add the following line to Win32::API after the line use Win32::API::Struct;:
    Win32::API::Type::myinit();

    The error goes away. The problem is that the INIT function is not being called.
    Best Regards,
    Mike