[fpc-pascal] [semi-off-topic] some C questions arising while using h2pas

Bernd prof7bit at googlemail.com
Fri Jul 15 13:43:27 CEST 2011


I am just trying to convert some openssl headers to Pascal (I know
that there is an openssl unit in the fpc packages but it is missing
the ECDSA functions which I will need later and which is main reason I
am starting to look into openssl).

To get used to this entire thing I am beginning with something much
more simple, I will try to get some sha hashing functions from openssl
imported (I will also need them, so it would not hurt to start with
them).

I am referring to the header file /usr/include/openssl/sha.h (pastebin
here: http://pastebin.com/dS8DY2z9 )

After appyling h2pas i have the following: http://pastebin.com/v3S3vtFR

If I want to import functions in Pascal I would either declare them
external and explicitly tell it the name of the library binary (this
seems straightforward to me, I see no problems with this) or I load it
dynamically at runtime and then ask for the addresses of the functions
that I need and assign them to procedure variables (I have also done
this already on some occasions and it is equally easy to understand
and also raises no questions).

I am confused about something else:

When looking at the .h file and also when looking at the generated .pp
file it seems that nowhere in the header there was any information
about which .so (or .dll) to load or link against. It created empty
bodies with { you must implement this function }. Now the question
(and I am intentionally asking this on a Pascal list and not a C list
to get an answer that better fits into my Pascal brain) how would the
C compiler or linker know from where exactly to import these
functions? Where is this information, how are these C folks doing
these things, what kind of magic have they going on?

confused,
Bernd



More information about the fpc-pascal mailing list