cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Error Compiling Curl

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 5 Mar 2002 00:13:46 +0100 (MET)

On Mon, 4 Mar 2002, Victor wrote:

> Any ideas what is causing this?
> Your support is greatly appreciated.

I might have a guess. See below.

> Making all in lib
> gmake[2]: Entering directory `/home/victord/curl-7.9.4/lib'
> /bin/sh ../libtool --mode=compile
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../src -I../include -I/usr/include/op
> enssl -I/usr/include -g -O2 -c -o file.lo `test -f file.c || echo
> './'`file.c
> rm -f .libs/file.lo
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../src -I../include -I/usr/include/openss
> l -I/usr/include -g -O2 -c file.c -fPIC -DPIC -o .libs/file.lo
> In file included from /usr/include/sys/vnode.h:42,
> from /usr/include/sys/stream.h:22,
> from /usr/include/netinet/in.h:41,
> from /usr/include/sys/socket.h:200,
> from file.c:44:
> /usr/include/sys/resource.h:193: warning: `struct rlimit64' declared inside
> parameter list
> /usr/include/sys/resource.h:193: warning: its scope is only this definition
> or declaration, which is probably not what you want.
> /usr/include/sys/resource.h:194: warning: `struct rlimit64' declared inside
> parameter list
> file.c: In function `Curl_file':
> file.c:158: incompatible types in assignment

What causes this compiler error is this line:

    expected_size = statbuf.st_size;

Where 'expected_size' is declared a ssize_t.

I think this is because your operating system header's have the 'st_size'
field of the 'struct stat' of a type that isn't possible to assign to a
"signed integer" which ssize_t is.

The solution?

Well, libcurl currently has no proper support for large files, so I think it
would be an idea (as a short-term fix) to make expected_size a double and
then typecast the assignment. Like in this patch:

diff -u -r1.22 file.c
--- lib/file.c 11 Oct 2001 09:32:19 -0000 1.22
+++ lib/file.c 4 Mar 2002 23:12:40 -0000
@@ -140,7 +140,7 @@
   */
   CURLcode res = CURLE_OK;
   struct stat statbuf;
- ssize_t expected_size=-1;
+ double expected_size=-1;
   ssize_t nread;
   struct SessionHandle *data = conn->data;
   char *buf = data->state.buffer;
@@ -155,7 +155,7 @@
 /*VMS?? -- This only works reliable for STREAMLF files */
   if( -1 != fstat(fd, &statbuf)) {
     /* we could stat it, then read out the size */
- expected_size = statbuf.st_size;
+ expected_size = (double)statbuf.st_size;
   }

   /* The following is a shortcut implementation of file reading

I'd be happy to get to know if this works.

I'm also interested in getting the large files support fixed once and for
all, should anyone want to grab that issue.

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2002-03-05