Delivered-To: listarch-cygwin AT sourceware DOT cygnus DOT com Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Message-Id: <199902152050.OAA22941@modi.xraylith.wisc.edu> X-Authentication-Warning: modi.xraylith.wisc.edu: LOCALHOST.xraylith.wisc.edu [127.0.0.1] didn't use HELO protocol To: Paul Sokoilovsky cc: cygwin AT sourceware DOT cygnus DOT com Subject: Re: __attribute__((dllimport)) problems with egcs In-reply-to: Your message of "Mon, 15 Feb 1999 18:22:21 +0200." <8765 DOT 990215 AT is DOT lg DOT ua> Date: Mon, 15 Feb 1999 14:49:55 -0600 From: Mumit Khan Paul Sokolovsky 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