[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: need advice on library interface



On Wed, Aug 07, 2002 at 05:39:32PM -0500, Joshua Haberman wrote:
> This was my initial idea.  The problem is that there is no reasonably
> portable 64-bit type that I know of.

That's what autoconf if for--find one and typedef it.  If you can't find
one at all, then fall back on a 32-bit type (or off_t itself.)

> AFAICS, _FILE_OFFSET_BITS vs. _LARGEFILE64_SOURCE is rather
> inconsequential since it will only affect interaction between libsndfile
> and libc.  I only care about interaction between client programs and
> libsndfile.

If _FILE_OFFSET_BITS=64 (= __USE_FILE_OFFSET64 = 1), off_t changes to
a 64-bit int.  If your library uses off_t in its interface, then this
will change the ABI.  (glibc uses __off_t and __off64_t internally,
which are unaffected by this, to avoid this problem, but you can't
safely use those.)

_LARGEFILE64_SOURCE merely makes off64_t and the 64-bit set of FS
functions available; it doesn't change anything.

A trick: both of these need to be defined before any system headers
are included, or features.h will be included and further changes will be
ignored.  That's a bit of a pain if the user includes system headers
before your library header.  I'm not sure of a good fix for this;
telling the user "include our header first" isn't very helpful.

-- 
Glenn Maynard



Reply to: