cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Problems with libcurl, OS X, and curl_off_t (or : What's My Size?)

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Sun, 15 Aug 2004 18:59:56 +0200 (CEST)

On Fri, 13 Aug 2004, Ryan Wilcox wrote:

> First of all, I'm using the config-mac.h file, instead of building it using
> straight configure/make/GCC.

That one is for Mac 9.

> #3: CVS HEAD is awfully hard to build on OS X... I had to get a new
> automake, libtool, and several other things. Then automake
> complained that the aclocal files were too old.

This is not unique for OS X. This is what we all face and this is what making
portable programs forces us to.

> In order to make this work I had to make the following modifications to
> configure-mac.h (which I will verify for Codewarrior, then submit a patch in
> the formal manner)

Sorry, but I will not accept a config-*.h file for a platform on which
configure is the prefered way.

If you want to avoid autoconf, automake and libtool etc, then get a daily
snapshot instead of CVS.

> You'll also notice SIZEOF_CURL_OFF_T is 8. It's 8 because OS X, like a normal
> POSIX system has curl_off_t defined as off_t. On OS X sizeof(off_t) == 8.
>
> Ok, that's grand. On OS X off_t seems to be a weird type. In thread entitled
> "libcurl putting an empty file on OS X", specifically this post
> (http://curl.haxx.se/mail/lib-2003-12/0237.html) seems to say that off_t may
> be "oddly" defined on OS X, but that casting your postSize parameter to a
> long solves the problem.

Eh, you confuse things here. *That* problem occurred because he passed an
off_t to a function that expected a long. Nothing else.

> To me this is weird, seemingly wrong, and doesn't work for large files
> (although sending 2GB files through HTTP isn't *my* idea of a good time.)
> Although it DOES work for me.

For large files, you pass in a curl_off_t type to the *_LARGE option.

> So, this morning I played around with setting curl_off_t to a long long
> instead

Isn't off_t already a long long on OS X?

>, using the define for GCC + Windows (I simply removed the Windows
> bit -- just for testing.). No go. My Content-Length was still == 0. I even
> redefined CURL_FORMAT_OFF_T to be "%lld" instead of "%l64d", as it is with
> GCC + Windows, with no luck.

CURL_FORMAT_OFF_T is not used internally within libcurl so there's no surprise
that your changes don't have any effect! :-)

> I really don't want to have to remember to cast things to longs every time I
> interact with curl_off_t

Why would you?

> #1: Just define curl_off_t to be a long on OS X, and set a compiler flag
> to turn off large file support (anybody happen to know that flag?)

If you don't want large file support, just don't use curl_off_t or the *_LARGE
options.

> #2: Find out, via the helpful folk on the libcurl list, why my plan with
> long long is either wrong, or "It's not working because you need
> to...".

First: what's wrong the current approach?

> #3: Make a sane format string for the OS X "different" implementation of
> off_t, if it really is "different".

The format string we use internally is for our own printf code, and that uses
long long on the platforms that support it. I'm pretty sure that includes OS
X.

> I know people have used libcurl on OS X

I'd even say that MANY people have.

-- 
      Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
       Dedicated custom curl help for hire: http://haxx.se/curl.html
Received on 2004-08-15