apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Duigou <apr-...@duigou.org>
Subject Re: apr_uint8_t and apr_int8_t?
Date Thu, 29 Jun 2006 16:24:10 GMT
Martin Sebor wrote:
> Mike Duigou wrote:
>> A patch to add apr_uint8_t and apr_int8_t to apr.h is attached. It 
>> also ensures that CHAR_BIT is 8 bits (it normally is) and that 
>> short_value and long_value are defined.
> 
> I normally just lurk here but this issue has caught my attention
> as I recently implemented the same thing in C++ and gained some
> insight into the gotchas behind these seemingly trivial typedefs.
> I hope you'll find it helpful.
> 
> First, char may be an unsigned type so apr_int8_t should be an
> alias for signed char in that case.

Very good point. I've updated my patch to correct this.

> Second, if APR headers are intended to be used in C++ programs
> (I don't know if that's possible or desirable), it would be a
> good idea to define apr_int8_t to the same type as int8_t in
> <stdint.h> and not simply to signed char unconditionally. Doing
> otherwise will prevent the two from being interchangeable and
> lead to compilation or linker errors in programs that mix and
> match them.

I've also updated the patch to use int8_t or uint8_t from <stdint.h> 
rather than "signed char" and "unsigned char" when stdint.h is available.

Thanks for the feedback! The updated patch is enclosed.

Mike

Mime
View raw message