This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


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

Re: latest release trouble using stat() with -mno-cygwin flag


NOE Nicolas wrote:
> 
> Hello,
> 
> I use stat() from sys/stat.h to get a file size in a C program,
> compiling with -mno-cygwin flag. It used to work before I updated
> to latest releases (cygwin, gcc and mingw), but now the stat
> structure seems to be melted, since I always get 4 as st_size, and
> that the real size seems to be in the st_atime field ! By the way,
> everything works fine without -mno-cygwin flag.
> 
> Maybe I should ask my question on the mingw list, but I don't know
> if the mingw included in cygwin distribution is just a copy of the
> latest mingw release or if some things are changed. If the bug
> comes from a faulty mingw, is there a safe way to remove my current
> one (mingw-20001225-1.tar.gz) and reinstall a previous one ?
> 
> I use the command line : gcc -mno-cygwin -o stat stat.c and my test
> program is the following (stat.c) :
> 
> #include <stdlib.h>
> #include <stdio.h>
> 
> #include <sys/stat.h>
> 
> int main(int argc, char *argv[])
> {
>         int             i;
>         struct stat     buf;
> 
>         for (i = 1; i < argc; i++)
>                 if (stat(argv[i], &buf))
>                         fprintf(stderr, "stat(): error\n");
>                 else
>                         printf("%s size is %d\n", argv[i], buf.st_size);
> 
>         return 0;
> }
> 

I've modified the MinGW runtime such that the GCC specs file is
incorrect with regard to the oldname library and you've used an old
name.  You have three options:

1) Don't use the oldname function, i.e.: use the _stat() version
instead.
2) gcc -o stat stat.c -lcoldname
3) Apply the attached patch:
   A) download diff file to /tmp/specs.diff.txt
   B) cd /
   C) patch -i /tmp/specs.diff.txt

Cheers,
Earnie
--- /lib/gcc-lib/i686-pc-cygwin/2.95.2-6/specs.orig	Wed Jan  3 12:01:40 2001
+++ /lib/gcc-lib/i686-pc-cygwin/2.95.2-6/specs	Tue Jan  9 08:08:45 2001
@@ -25,3 +25,3 @@
 *libgcc:
-%{mno-cygwin: %{mthreads:-lmingwthrd} -lmingw32} -lgcc %{mno-cygwin:-lmoldname -lcrtdll}
+%{mno-cygwin: %{mthreads:-lmingwthrd} -lmingw32} -lgcc %{mno-cygwin:-lcoldname -lcrtdll}
 

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

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