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

No extern allowed in namespace

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Affects Version/s: 1.2.x
    • Fix Version/s: 5.11.0
    • Component/s: Shiboken
    • Environment:
      64-bit Linux with gcc 4.6.2

      Description

      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>
      

        Attachments

          Issue Links

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

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes