This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project. See the Cygwin home page for more information.
[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index] [Subject Index] [Author Index] [Thread Index]

__attribute__((dllimport)) problems with egcs



Hello Mumit,

      Egcs 1.1.1 has problems with dllimport attribute, inherent from
1.1. Here's sample code to show them:

--------
typedef struct _object {
   int ob_refcnt; struct _typeobject *ob_type;
} PyObject;

extern    __attribute__((dllimport))  PyObject   _Py_NoneStruct ;  

static PyObject *
parse_and_bind(PyObject *self,PyObject *args)
{
  return &_Py_NoneStruct;
}  
---------

  Both C and C++ frontends have problems, C++ fatal ones.

  When that code compiled in C mode, following warning is issued:
---
a.c: In function `parse_and_bind':
a.c:10: warning: return from incompatible pointer type  
--
  Of course, it's not there without __attribute__((dllimport)).


  When compiled in C++ mode, it just crashes. Further
investigation by feeding code directly to cc1plus shows that crash
occurs not on declaring _Py_NoneStruct, but on referencing it
(compiler have time to print "struct PyObject * parse_and_bind(struct
PyObject *, struct PyObject *)"). Then, it seems that referencing
method plays role too: for example, returning structure itself doesn't
cause problems. Crash itself due to null pointer dereference at 0x00438b5f.

Best regards,
 Paul                          mailto:paul-ml@is.lg.ua