<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><span class=""></span><span class="">Dear all,</span><span class=""><br class=""><br class=""></span><span class="">I am facing an issue with correcty implementing a template (container)) in SIP.<br class=""></span><span class=""><br class=""></span><span class="">Let’s say I have<br class=""></span><span class=""><br class=""></span><span class="">qgsoptional:<br class=""></span><span class="">template<class T><br class="">class QgsOptional<br class="">{<br class="">  public:<br class="">    QgsOptional( const T &data, bool enabled )<br class="">      : mEnabled( enabled )<br class="">      , mData( data )<br class="">    {}<br class="">  private:<br class="">    bool mEnabled;<br class="">    T mData;<br class="">};<br class=""><br class="">qgsoptionalexpression.h:<br class=""><br class="">class QgsOptionalExpression : public QgsOptional<QgsExpression><br class="">{<br class="">  public:<br class="">    QgsOptionalExpression();<br class="">}<br class=""><br class=""><br class=""></span><span class="">Now, I’d like to create the SIP file for QgsOptioalExpression. I tried with what I found in another topic [0]:</span><div class=""><br class=""></div><div class=""><span class="">class QgsOptionalExpression<br class="">{<br class="">%TypeHeaderCode<br class="">#include "qgsoptional.h"<br class="">typedef QgsOptional<QgsExpression> QgsOptionalExpression;<br class="">%End<br class="">  public:<br class="">    QgsOptionalExpression();<br class="">}</span></div><div class=""><span class=""><br class=""></span></div><div class=""><span class="">But this gives me this error:</span></div><div class=""><span style="color: rgb(38, 50, 56); font-family: Roboto, Arial, sans-serif; font-size: 13px; font-variant-ligatures: normal; orphans: 2; widows: 2;" class="">python/core/qgsoptionalexpression.sip:29:36: error: typedef redefinition with different types ('QgsOptional' vs 'QgsOptionalExpression')</span><br style="color: rgb(38, 50, 56); font-family: Roboto, Arial, sans-serif; font-size: 13px; font-variant-ligatures: normal; orphans: 2; widows: 2;" class=""><span style="color: rgb(38, 50, 56); font-family: Roboto, Arial, sans-serif; font-size: 13px; font-variant-ligatures: normal; orphans: 2; widows: 2;" class="">typedef QgsOptional QgsOptionalExpression;</span></div><div style="orphans: 2; widows: 2;" class=""><font color="#263238" face="Roboto, Arial, sans-serif" size="2" class="">The error points that the definition is already included in the header qgsoptionalepxression.h while I am actually not including it here (also gave it a try with including it).</font></div><div style="orphans: 2; widows: 2;" class=""><font color="#263238" face="Roboto, Arial, sans-serif" size="2" class=""><br class=""></font></div><div style="orphans: 2; widows: 2;" class=""><font color="#263238" face="Roboto, Arial, sans-serif" size="2" class="">I understand the point, but how shall I tackle this?</font></div><div style="orphans: 2; widows: 2;" class=""><font color="#263238" face="Roboto, Arial, sans-serif" size="2" class="">If I remove the inheritance, I’m of course not getting any of the container methods.</font></div><div style="orphans: 2; widows: 2;" class=""><font color="#263238" face="Roboto, Arial, sans-serif" size="2" class="">I also gave it a try with a ModuleHeaderCode:</font></div><div style="orphans: 2; widows: 2;" class=""><font color="#263238" face="Roboto, Arial, sans-serif" size="2" class=""><br class=""></font></div><div style="orphans: 2; widows: 2;" class=""><font color="#263238" face="Roboto, Arial, sans-serif" size="2" class=""><div class=""> %ModuleHeaderCode</div><div class=""> #include "qgsoptional.h"</div><div class=""> #include "qgsexpression.h"</div><div class=""> typedef QgsOptional<QgsExpression> QgsOptionalExpression;</div><div class=""> %End</div><div class=""><br class=""></div><div class="">But it fails with the same kind of error, complaining the type is already defined in the header (also with or without including it in the TypeHeaderCode.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Any idea how to solve this?</div><div class="">Thanks a lot!</div><div class=""><br class=""></div><div class="">Denis</div></font></div><div class=""><br class=""></div><div class=""><span class=""><br class=""></span></div><div class=""><span class="">[0] </span><a href="https://www.riverbankcomputing.com/pipermail/pyqt/2015-May/035893.html" class="">https://www.riverbankcomputing.com/pipermail/pyqt/2015-May/035893.html</a><span class=""><br class=""></span><span class=""><br class=""></span><span class=""><br class=""></span><span class=""><br class=""></span><span class=""><br class=""></span></div></body></html>