delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/02/15/20:52:38

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 <paul-ml AT is DOT lg DOT ua>
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 <khan AT xraylith DOT wisc DOT EDU>

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019