SV: [fpc-pascal] Resending: Trying to convert some C code

Ole J. Røtne ole.rotne at
Tue Nov 7 13:24:27 CET 2006

Thanks for the replies

> -----Opprinnelig melding-----
> Fra: fpc-pascal-bounces at 
> [mailto:fpc-pascal-bounces at] På vegne av 
> Henry Vermaak
> Sendt: 7. november 2006 12:19
> Til: FPC-Pascal users discussions
> Emne: Re: [fpc-pascal] Resending: Trying to convert some C code
> i'm no guru, but here's a couple of things that you might try:
> {$PACKRECORDS C} to make sure about that struct (gives me 
> problems on osx if i don't use it)

Ok, trying that.
> >   BN_ULONG *d;
> what is BN_ULONG?  make sure it's the same size of:
> >     d:pointer;

BN_ULONG is just another way of saying unsigned long.
But redefined because it's C & for different compilers/platforms i think.

> you forgot the calling convention here:
> > Type
> >   TBN_bn2hex = function(a:BNPtr):PChar;
> should have cdecl?

Have it, but typing error :-S

> >   LibHandle := LoadLibrary('libeay32.dll');
> >   _BnBn2Hex := GetProcAddress( BnLibHandle, 'BN_bn2hex');
> i assume that LibHandle should be BnLibHandle?  what are the 
> errors you get?

Yes it is.. Was typing this abit to fast after my kid sent the first before
i was done.

And my code does compile, but bomb with a unhandled exception when i use the
That made me wonder if my parameters to the function was converted right..

As in, is this right "way" to convert parameter & return value..?

char *BN_bn2hex(const BIGNUM *a);

function BN_Bn2Hex(a:BNPtr):PChar; // here BNPtr is of type BNPtr:^BIGNUM

> to get the general idea, see:

Will take a look..

Ole JR

More information about the fpc-pascal mailing list