robertwb / issues-import-test

0 stars 0 forks source link

C++ compile error when exception part declared on function #74

Closed robertwb closed 8 years ago

robertwb commented 8 years ago

Reported by d brooks on 6 Aug 2008 08:37 UTC The following results in gcc 4.01 reporting "error: invalid conversion from const char* to char*" when using Cython 0.9.8

test.pyx:

cdef extern from "test.h":
  ctypedef struct c_Test "Test":
    char *getString() except +RuntimeError
                     ## All OK if no 'except +RuntimeError'
cdef class Test:
  cdef c_Test *thisptr
  def getString(self):
    return self.thisptr.getString()

test.h:

static const char *astring = "123" ;
class Test {
 public:
  const char *getString(void) { return astring ; }
  } ;

setup.py:

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

setup(
  name = 'biosigpy',
  ext_modules = [   Extension('test', ['test.pyx'](
),
      language='c++',
      extra_link_args=[     )
    ]("-g"],
),
  cmdclass = {'build_ext': build_ext}
  )

Migrated-From: http://trac.cython.org/ticket/42

robertwb commented 8 years ago

Modified by robertwb on 19 Aug 2008 04:37 UTC

robertwb commented 8 years ago

Comment by robertwb on 28 Oct 2008 19:39 UTC This is not an error with except, so much as it is an error with const. See http://wiki.cython.org/FAQ#head-af019db12f683abe6bc226926e8a2a92425b8e57 on how to handle this until we get full const support (which is not as trivial as one might suppose).

robertwb commented 8 years ago

Modified by robertwb on 28 Apr 2013 07:24 UTC