[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AC_CHECK_SIZEOF for members
From: |
Paul Eggert |
Subject: |
Re: AC_CHECK_SIZEOF for members |
Date: |
Wed, 11 May 2005 11:05:53 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) |
Sam Steingold <address@hidden> writes:
>> Yes, that's correct. You'd need to write a variant to do what you want.
>
> <screaming in pain>
It's not that bad, if you can assume Autoconf 2.59. Just copy the
existing code from the sizeof-using macro, and repair it to allow
objects rather than types.
> the reason I want a CPP macro and not a run-time if is that the code
> will end up looking like this:
>
> if (size_of(u.ut_tv.tv_sec) = 4)
> a_function_expecting_32_bit_argument(u.ut_tv.tv_sec);
> else
> a_function_expecting_64_bit_argument(u.ut_tv.tv_sec);
>
> the result is that on _each_ platform there will be a compile-time
> warning about a wrong argument type.
My suggestion is to fix the compiler, or get a better compiler, or
ignore the warnings. Your life is too short to waste it worrying
about incorrect compiler warnings.
Also, unless there is a serious efficiency issue (not likely here) or
some other issue I don't quite follow, I'd write the code like this:
a_function_expecting_64_bit_argument (u.ut_tv.tv_sec);
This will work fine on C89 and better, if you've prototyped the function.