[PyKDE] More on GCC 2.96

Phil Thompson phil at river-bank.demon.co.uk
Thu Oct 12 11:14:55 BST 2000

Johannes Sixt wrote:
> On Wed, 11 Oct 2000, you wrote:
> >Jesper Eskilson wrote:
> >>
> >> When compiling PyQt using 2.96, I get the following error messages:
> >>
> >> c++ -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include/python2.0 -I/usr/local/include/sip -I/usr/local/qt-2.2.1/include -I/usr/X11R6/include -fno-exceptions -O2 -Wp,-MD,.deps/sipqtQWhatsThis.pp -c  -fPIC -DPIC sipqtQWhatsThis.cpp -o sipqtQWhatsThis.lo
> >> sipqtQWhatsThis.cpp: In function `PyObject *sipNew_QWhatsThis (PyObject
> >> *, PyObject *)':
> >> sipqtQWhatsThis.cpp:1020: cannot convert `sipProxy *(*) ()' to `void *'
> >> in initialization
> >>
> >> One workaround is to add an explicit cast to (void *), but there seems to
> >> be a lot of places where this needs to be done, and most of them are in
> >> automaticall generated code (by sip). I tried to hack sip to emit the
> >> void-cast directly, but the files above does not seem to be re-generated
> >> when building PyQt.
> >
> >Is it invalid C++ to assign something to a void * without a cast? (I
> >know its invalid to do the reverse.)
> It is only allowed to cast pointers to objects to void*, but not pointers to
> functions. You need a reinterpret_cast<void*>(xyz) to cast in one direction,
> and a reinterpret_cast<sipProxy*(*)()>(zyx) to convert the value back. (But you
> better think over the whole construct again - do you really require such dirty
> hacks? Can't you get away with a union {}? That would be slightly cleaner.)

The reason for using void * is not because pointers to a variety of
types are being stored but because I don't want to declare the type of
the pointer in the sip.h header file. This is part of my dim and distant
plan that SIP should one day be used for generating bindings for C
libraries as well as C++ libraries - and why most of the SIP library is
written in C and only the parts that implement Qt support are in C++.

I'm not saying that there isn't a better way of doing it.


More information about the PyQt mailing list