std C/C++ patch #11
David Scott Page
page at cs.utexas.edu
Tue Apr 30 12:22:14 EDT 2002
Eddie,
> I updated the various click_*.h bitfields to use 'unsigned'. It annoys me
> that C++ standard explicitly allows 'inteGRAL' types, while C99 forces
> 'int' or 'unsigned'.
I thought it was odd, too (the C99 standard does allow for
implementation defined types, rather than forbidding them). But after
thinking about it some more, I really prefer a simple signed or
unsigned (or _Bool/bool) type, since, e.g., in the case of ip header,
uint8_t seems to be trying to convey that version and length are each
4 bits of an 8 bit field, which is really just an artifact of the host
architecture, rather than the wire syntax.
> Also solved the 'inline' problem with AC_C_INLINE.
>
> clp.h patch: I don't understand why [u]int64_t doesn't work on Solaris when
> 'long long' does. '#include <click/config.h>' is meant to provide the
> following guarantee:
>
> Either HAVE_INT64_TYPES is not defined,
> OR the typedef names 'int64_t' and 'uint64_t' are 64-bit integer
> types.
>
> Your patch acts like the guarantee was broken. I'm not accepting the patch.
> Can you explain what is wrong with config.h or configure.in?
I believe the config test is done with the C++ compiler and the C
compiler is the one objecting. Someone at Sun decided (from
inttypes.h):
#ifdef _LP64
typedef long int64_t;
#else /* _ILP32 */
#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
typedef long long int64_t;
#endif
Since for standard C, __STDC__ is non-zero, and, by definition,
__STDC__ should not be non-zero when __cplusplus is, the explicit
64-bit types are allowed in C++, but not C, for ILP32 environment
(perhaps some POSIX thing?). Techincally, while long long is part of
the C99 standard, it is not a C++ fundamental type (standard p. 53),
but the KCC compiler has a flag dedicated to allowing (unsigned) long
long.
By the way, thanks for taking the time to get this all sorted out -
I'm all for standards compliance where it makes sense, but some of
gcc's extensions can really simplify coding (and gcc is probably one
of the main drivers of innovation in C/C++ language development).
--
Scott Page
More information about the click
mailing list