This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Unreviewed cygwin/mingw dllimport patch for PRs 5287. 7910, 11021


 --- Jason Merrill <jason@...> wrote: > On Thu, 12 Jun 2003 08:20:42 +1000 (EST), Danny Smith
<danny_r_smith_2001@...> wrote:
> 
> > My reason for the test for TREE_STATIC of dllimport'd variables in this:
> >
> > if (is_attribute_p ("dllimport", name)) 
> >     &&TREE_CODE (node) == VAR_DECL)
> >   {
> >     if (!TREE_STATIC (node))
> >      /* This is needed for declarations of variables within functions */
> >       TREE_PUBLIC (node) = 1; 
> >     DECL_EXTERNAL (node) = 1;
> >   }
> >
> > /* This is for all dllimport/export'd symbols */
> > if (! TREE_PUBLIC (node))
> >    error ("external linkage required")
> >
> >
> > is to allow this, by setting TREE_PUBLIC as well DECL_EXTERNAL:
> >
> > void foo()
> > {
> >   __attribute__((dllimport))
> >   int foovar;     // OK,  implicit "extern" 
> >   foovar++;
> > }
> 
> That's horrible.  That should be an error; foovar is an automatic variable.
> Does VC++ allow this?


VC++ explicitly documents this as supported. 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang98/html/_pluslang_definitions_and_declarations.asp


 And if I change the attribute to __declspec(dllimport), then cl.exe 
compiles without warning even with all warnings  turned on,

Danny

http://mobile.yahoo.com.au - Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]