[fpc-pascal] Parallel Port Access with Free Pascal - windows

James Richters james at productionautomation.net
Sat Jul 23 12:22:56 CEST 2016

I get 
Error: Calling convection doesn't match forward
Error: Found Declaration: IsInpOutDriverOpen:Boolean;

Do I need to specify the functions differently in the interface section?
Thanks for the help

-----Original Message-----
From: fpc-pascal-bounces at lists.freepascal.org
[mailto:fpc-pascal-bounces at lists.freepascal.org] On Behalf Of Marc Santhoff
Sent: Saturday, July 23, 2016 1:09 AM
To: fpc-pascal at lists.freepascal.org
Subject: Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows

On Sa, 2016-07-23 at 05:55 +0200, Marc Santhoff wrote:
> On Fr, 2016-07-22 at 18:20 -0400, James Richters wrote:
> > I'm trying to avoid custom hardware if possible.  I have always used
> > parallel ports and never had a problem with them until now.   I like the
> > idea of a parallel port because they are still built onto motherboards,
> > there are also a TON of USB to parallel port adapters out there.   I'm
> > trying to keep this simple.
> > 
> > I put a repository of my test program here:
> > https://github.com/Zaaphod/FPC-Parallel-Port.  Perhaps someone can see
> > I'm doing wrong.    I'm reading 255s no matter what I do.    I included
> > old turbo pascal test program.  I would normally specify the port in 
> > hex with a $ like this $378.  I could write to the port then read 
> > back what I just wrote.. which is what I am trying to do now.. I 
> > don't have anything hooked up to the port yet, I should be able to write
to it and read it back.
> > 
> > I seem to be accessing the DLL correctly, because I tried it on a 
> > windows 7 computer and  IsInpOutDriverOpen was false, because I 
> > forgot to install the driver, once I installed the driver 
> > IsInpOutDriverOpen is now true, so that tells me I'm accessing the DLL
and the DLL is confirming the driver is open.
> >From what I know, although it may be a bit outdated, on windows 
> >external
> functions have to be declared 'cdecl'. Which isn't so in the library 
> port to pascal.
> One example:
>   implementation
>   Function IsInpOutDriverOpen; external 'inpout32.DLL';
> would then be:
>   implementation
>   Function IsInpOutDriverOpen; cdecl; external 'inpout32.DLL';

No, sorry. It has to be the other way round:

  Function IsInpOutDriverOpen; {$ifndef Win32}cdecl{$else}stdcall{$endif};
external 'inpout32.DLL';

I didn't recognize that it is  $ifndef, not $ifdef.


fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org

More information about the fpc-pascal mailing list