Holger Kiehl wrote:

> I would like to have an unsigned off_t, what is the best and portbale way
> to define this? Currently I use the following code:
> 
>     #if SIZEOF_OFF_T == 4
>     typedef unsigned long       u_off_t;
>     #else
>     typedef unsigned long long  u_off_t;
>     #endif
> 
> SIZEOF_OFF_T is returned from the gnu autoconfig tools.
> 
> Is this the correct way of doing this?

There isn't any "correct" way of doing it.

> Or is there some better more portable way?

Using the types from stdint.h (uint32_t, uint64_t etc) would be more
portable than making assumptions about the sizes of "long", "long long"
etc. Alternatively:

        #if SIZEOF_OFF_T == SIZEOF_INT
        typedef unsigned int off_t
        #elif SIZEOF_OFF_T == SIZEOF_LONG
        typedef unsigned long off_t
        #elif SIZEOF_OFF_T == SIZEOF_LONG_LONG
        typedef unsigned long long off_t
        #endif

Out of curiosity, why do you want an unsigned off_t anyhow?

-- 
Glynn Clements <[EMAIL PROTECTED]>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" 
in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to