This will be my first attempt to code a DLL in Delphi for calling from other languages.
I have done a lot of googling and see a few good pointers, but nothing exhaustive (at least, I have questions that don't find answered in the Embarcadero material).
I wonder if this list of caveats is exhhaustive, or if I missed anything, and if anyone can anser my questions below.
- if I want my DLL to be callable from other languages, then i can't use the
ShareMem
unit. - I can't use the
String
type and should stick withPChar
- if I want to return a string, the caller should pass me a buffer to write it to (I should not alloctae the memory for it myself, even if I provide a routine to free it afterwards)
- I should stick to simple types like
integetr
andPChar
(any others?)
A few questions:
- the comipler forbids me to export enums and constants. Am I just not declaring them correctly? I would like calling Delphi s/w to be able to use the enum elements and all callers to be able to use constants.
- I should not use any structures because of possible differences in byte alignment between compilers. So, if I can't accept strctures as parameters. I guess I should just have a long parameter list of
integer
s andPChar
s? - can I accept arrays as parameters, or does boundary alignment make that dangerous?
- can I accept/return floats/doubles ?
booleans? Or am I stuck with "zer0 === false and all else is true"?
is there anything else I should know?
Thanks in advance for any help