Hit bug in sip wrapper generation of template expansion involving enums

Gehlhaar, Daniel Kurt dan.gehlhaar at pfizer.com
Wed Mar 3 23:43:54 GMT 2021


I hit a problem moving from sip 4.19.3 to sip 6.0.2 involving the code generation relating to the following sample, specifically the QMap<MyEnum,QColor>:


#ifndef COLORS_H
#define COLORS_H

#include <qcolor.h>
#include <qobject.h>
#include <qmap.h>
#include "DefinesMyEnum.h"

class Colors : public QObject
{
  Q_OBJECT;

public:
  Colors();

  const QMap<MyEnum, QColor> &GetColors() const
    { return colors; }

protected:

  QMap<MyEnum, QColor> colors;
};

#endif


#ifndef DEFINES_MY_ENUM_H
#define DEFINES_MY_ENUM_H

enum MyEnum
  { THIS, THAT };

#endif

%Module Colors

class Colors : QObject
{
%TypeHeaderCode
#include "Colors.h"
%End

public:
  Colors();

  const QMap<MyEnum, QColor> &GetColors() const ;
};

In sip 4.19.3, each .sip file generated a .cpp file. In sip 6.0.2, this is not necessarily the case. In this case, the QMap<MyEnum,QColor> gets wrapped in its own .cpp file that DOES NOT INCLUDE the definition of the MyEnum type (i.e. it does not include "DefinesMyEnum.h").  This results in myriad compiler errors:

sipPyTESTQMap0100MyEnum0100QColor.cpp(18): error C2065: 'MyEnum': undeclared identifier
sipPyTESTQMap0100MyEnum0100QColor.cpp(18): error C2923: 'QMap': 'MyEnum' is not a valid template type argument for parameter 'Key'

Please fix, or let me know what I need to do on my end to fix.

Thanks,
Dan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210303/52393814/attachment-0001.htm>


More information about the PyQt mailing list