Further questions on interfacing to Postgres libpq
Joe
jma at freedomcircle.com
Sat Jan 27 05:11:51 UTC 2018
An example test program that I'm using to learn D to C
interfacing (specifically calling the libpq library) has a call
to a C function declared as follows:
void PQprint(FILE *fout, /* output stream */
const PGresult *res,
const PQprintOpt *po);
PQprintOpt is a struct whose first six members are declared as
'pqbool' which is in turn declared as "typedef char pqbool;" in
the distributed Postgres header file. I've defined an "alias
pqbool = char;" in the D file, which is pretty straightforward.
The second of the six members has the name "align", which is a D
keyword. So I renamed it "align_" and I presume that won't cause
any problems.
To deal with the first argument to PQprint, I added "import
core.stdc.stdio : FILE;". The question is how to pass the D
"stdout" as that argument. The D compiler tells me I can't pass
it as is (as was done in C), because in D it's of type "File".
More information about the Digitalmars-d-learn
mailing list