Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-80

No extern allowed in namespace

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P3: Somewhat important P3: Somewhat important
    • 5.11.0
    • 1.2.x
    • Shiboken
    • 64-bit Linux with gcc 4.6.2

      Declaring a variable to be "extern" inside a namespace causes Shiboken to generate invalid code. I have attached a patch file to recreate the problem using the libsample test case from the Shiboken source code. To summarize:

      // In header file
      namespace SampleNamespace
      {
      //...
      extern int ExternInt;
      }
      
      // In implementation file
      namespace SampleNamespace
      {
      //...
      int ExternInt = 0;
      }
      

      This causes shiboken to produce invalid code like the following:

      static PyObject* Sbk_SampleNamespace_get_ExternInt(PyObject* self, void*)
      {
          ::SampleNamespace* cppSelf = 0;
      //...
      

      which causes gcc 4.6.2 to complain like so

      In function ‘PyObject* Sbk_SampleNamespace_get_ExternInt(PyObject*, void*)’:
      error: expected primary-expression before ‘*’ token
      error: ‘cppSelf’ was not declared in this scope
      error: expected primary-expression before ‘;’ token

      A workaround is to add a rejection tag to the typesystem

      <namespace-type name="SampleNamespace">
          <!-- ... -->
          <rejection class="*" field-name="ExternInt" />
      </namespace-type>
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            kleint Friedemann Kleint
            jcummings John Cummings
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes