Compile warning in times.cc and strace.exe compile problem

Mumit Khan khan@NanoTech.Wisc.EDU
Sat Mar 18 11:34:00 GMT 2000


John Fortin <fortinj@attglobal.net> writes:
> Chris Faylor wrote:
> > 
> > On Sat, Mar 18, 2000 at 10:14:59AM -0500, John Fortin wrote:
> > >When I compile cygwin from the cvs extract, times.cc gets the following:
> > >
> > >
> > >gcc -c -g -O2 -o ./times.o times.cc
> > >/e/src/winsup/cygwin/times.cc:20: warning: inconsistent dll linkage for
> > >`time_t
> > >_timezone'. dllexport assumed.
> > >/e/src/winsup/cygwin/times.cc:21: warning: inconsistent dll linkage for
> > >`int _da
> > >ylight'. dllexport assumed.
> 
> I'm using (I think ?) the newlib from CVS which was created when I did
> 'cvs get winsup'.
> Is this the correct version?

This happens due to dllimport/export override rules, and typically
results in the correct behaviour (as is the case with Cygwin DLL).
The warning is there only to make sure developers know what's happening 
internally, and I added it since VC++ does the same.

Let's say you have some variable `foo_imported' imported from a DLL, and
it's declared in the user visible include file `foo.h'.

  /* foo.h */
  extern int foo_imported __attribute__((dllimport));

Now user that includes foo.h will get the right declaration and will link
it in from the DLL.

For the DLL code however, you should export it as the following:

  /* foo_implement.c */
  int foo_imported __attribute__((dllexport));

But let's say you forgot: 

  /* foo_implement.c */
  int foo_imported;

In which case VC++ override rule says that it should be exported instead,
which is the most likely intent. This was I imagine to help DLL code that
forgot to add the dllexport attribute. 

Regards,
Mumit



More information about the Cygwin-developers mailing list