I meet a problem in my code:<br><br>hello.h:<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">#include<QtCore><br><br>class Hello : public QObject{<br>
    Q_OBJECT<br>public:<br>    Hello(QObject *parent = 0);<br>    static int test(){<br>        static int i=0;<br>        qDebug()<<i++;<br>        return 0;<br>    }<br>};<br></blockquote><br>hello.cpp:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
#include "hello.h"<br><br>const int i=Hello::test();<br><br>Hello::Hello (QObject *parent)<br>{<br>}<br></blockquote><br clear="all">hello.sip<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
%Module hello<br><br>%Import QtCore/QtCoremod.sip<br><br><br>class Hello : public QObject {<br><br>%TypeHeaderCode<br>#include "hello.h"<br>%End<br><br>public:<br>     Hello(QObject *parent = 0);<br>     static int test();<br>
};<br></blockquote><br>I use the<i> const int i=Hello::test();</i> to invoke test() before <i>main</i> function.It's uesful in <span class="label_list">factory pattern when you want to auto </span><span class="label_list">
</span>register driver.<br><br>the python test code<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">import hello<br>hello.Hello.test1()<br></blockquote>
<br>It seems <i>static int i</i>  in <i>test() </i>changed after <i>import hello</i><br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">Breakpoint 1, Hello::test1 () at hello.h:8<br>
8           static int test1(){<br>(gdb) p i<br>$1 = 0<br>(gdb) p &i<br>$2 = (const int *) 0x7ffff60300d0<br>(gdb) c<br>Continuing.<br>0 <br><br>Breakpoint 1, Hello::test1 () at main.h:8<br>8           static int test1(){<br>
(gdb) p &i<br>$3 = (const int *) 0x7ffff60300d0<br>(gdb) n<br>10              qDebug()<<i++;<br>(gdb) p &i<br>$4 = (int *) 0x7ffff62355c0       <---What happen here?<br></blockquote><br><br>Thx for reading.<br>
<br>-- <br>                                                       <br><br>DY.Feng(叶毅锋)<br>yyfeng88625@twitter<br>Department of Applied Mathematics<br>Guangzhou University,China<br><a href="mailto:dyfeng@stu.gzhu.edu.cn" target="_blank">dyfeng@stu.gzhu.edu.cn</a><br>
                                                       <br>