Mail Archives: cygwin/1999/02/15/20:52:38
Paul Sokolovsky <paul-ml AT is DOT lg DOT ua> writes:
> 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
> --
Thanks for the bug report. This is one of two known bugs I had mentioned
earlier; good news is that it's fixed in the development branch, but the
bad news is that it will *not* be fixed in upcoming egcs-1.1.2.
Here's a workaround until egcs-1.2.x:
typedef struct __attribute__((dllimport)) _object {
int ob_refcnt; struct _typeobject *ob_type;
} PyObject;
This is also the recommended way, even in MSVC, to tag whole structures
and classes as exported/imported.
This is what I do in headers (replace __IMPORT__ with something that
doesn't violate ANSI namespace):
#if BUILDING_DLL
# define __IMPORT__ __attribute__((dllexport))
#else
# define __IMPORT__ __attribute__((dllimport))
#endif
class __IMPORT__
foo
{
// ...
};
Regards,
Mumit
- Raw text -