[PyQt] Possible bug in the handling of sipTypeInstanceDef for const data

Shaheed Haque srhaque at theiet.org
Tue Sep 5 17:42:55 BST 2017


On 5 Sep 2017 16:50, "Phil Thompson" <phil at riverbankcomputing.com> wrote:

On 30 Aug 2017, at 8:44 pm, Shaheed Haque <srhaque at theiet.org> wrote:
>
> Hi Phil,
>
> I have a bit of C++ like this:
>
> ========
> typedef struct prob {
>    int p_range;
>    int p_offset;
> } Prob;
>
> static const Prob freqs[16] = {
>    {0, 0},   ...
> };
> ========
>
> (all this is at global scope). The SIP I create for this is:
>
> ========
> struct prob
> {
> %TypeHeaderCode
> #include <MessageViewer/KXFace>
> %End
>    int p_range;
>    int p_offset;
> };
>
> const prob *freqs /NoSetter/;
> ========
>
> In response, SIP creates this code which does not compile, complaining
> "error: invalid conversion from ‘const void*’ to ‘void*’":
>
> ========
> /* Define the class and enum instances to be added to this module
dictionary. */
> static sipTypeInstanceDef typeInstances[] = {
>    {sipName_freqs, & ::freqs, &sipType_prob, SIP_INDIRECT},
>    {0, 0, 0, 0}
> };
> ========
>
> Inserting a cast to make the second filed look like "(void *)&
> ::freqs" suppresses the error. Now, I could probably cook up a patch
> to do this, but I'm not sure if the correct fix is actually to change
> the definition of the field to "const void *ti_ptr"?
>
> Any thoughts?

Tonight's snapshot has the cast.


Thanks for the quick turnaround as usual! I'll add the patch to my Python 2
code as Clang has still not released Python 3 support...

Shaheed


Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170905/defa507f/attachment.html>


More information about the PyQt mailing list