[PyKDE] sipping char[N] datatypes in structs

Jonathan Gardner jgardner at jonathangardner.net
Fri May 16 05:12:01 BST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

sip -V -> 3.5 (build 57) 

I am doing my first sip of a C header file (or any file for that matter). 
Please pardon me for my naivety. I did read through the two books 
referenced by the sip documentation site. They were pretty helpful. I still 
have a lot of questions, naturally.

For reference, I am doing a sip interface to the postgresql C library 
(libpq). You can find the header I am working from normally somewhere 
around /usr/include/libpg-fe.h. I am working off of Red Hat 8.0, so it is 
in the postgresql-devel package.

I am doing this because I wanted a "closer to the metal" interface. There 
are probably a few things I will smooth out (like freeing memory with the 
supplied PQ functions, etc..) later on. For now, I just want the bare 
metal.

I got some of the stuff working -- like enum and some function calls. 
However, I am having a bit of trouble with the structs.

There are some structs that are opaque. For example, in the header:

typedef struct pg_conn PGconn;

So, in the .sip file, I put the same. For functions that return a pointer to 
the struct, it seems to work okay. It returns a sip.voidptr when called in 
python. I guess this won't cause a lot of problems, because PGconn is 
supposed to be opaque.

Now for transparent structs. It seems as long as I change it around so it 
reads:

struct  StructName { ... };

instead of:

extern struct _StructName { ... } StructName;

it works okay. I was able to get PQconninfoOption working in this way.

This sucker won't sip, though:

struct PGnotify
{
	char		relname[NAMEDATALEN];
	int			be_pid;
};

If I do "char *relname", then it won't compile because char * is not the 
same as char[32] (NAMEDATALEN is defined to be 32).

Any tips?

- -- 
Jonathan Gardner
jgardner at jonathangardner.net
(was jgardn at alumni.washington.edu)
Live Free, Use Linux!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE+xFdpWgwF3QvpWNwRAiMdAJ9tjyyJSwENpYygmM6o+RKjVH+hQQCgt3fm
Vt23feyemg252A+SLUhBWlg=
=tcKV
-----END PGP SIGNATURE-----




More information about the PyQt mailing list