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]
Re: __attribute__((dllimport)) problems with egcs
- To: Paul Sokoilovsky <paul-ml@is.lg.ua>
- Subject: Re: __attribute__((dllimport)) problems with egcs
- From: Mumit Khan <khan@xraylith.wisc.EDU>
- Date: Mon, 15 Feb 1999 14:49:55 -0600
- cc: cygwin@sourceware.cygnus.com
- Delivered-To: listarch-cygwin@sourceware.cygnus.com
- Delivered-To: mailing list cygwin@sourceware.cygnus.com
- In-reply-to: Your message of "Mon, 15 Feb 1999 18:22:21 +0200." <8765.990215@is.lg.ua>
- Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm
- Sender: cygwin-owner@sourceware.cygnus.com
Paul Sokolovsky <paul-ml@is.lg.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