samba4: unsigned char -> uint8

Anthony Liguori aliguor at us.ibm.com
Wed Jun 2 19:45:38 GMT 2004


Using uint_t and int_t may be a bad idea.  The C99 standard specifically 
reverses the right to introduce new types that begin with int or uint and 
end with _t.  There's no guarentee that their definition would be the same 
as ours either and that could produce compatibility problems moving 
forward.  Currently int_t and uint_t are not defined in C99.  Here's the 
relevant text from the standard:

        7.26  Future library directions

       [#1]  The  following  names  are  grouped  under  individual
       headers for convenience.  All external names described below
       are  reserved  no  matter  what  headers are included by the
       program.

... a little further down ...

      7.26.8  Integer types <stdint.h>

       [#1] Type names beginning with int or uint and  ending  with
       _t  may  be  added  to  the  types defined in the <stdint.h>
       header.  Macro names beginning with INT or UINT  and  ending
       with _MAX or _MIN, may be added to the macros defined in the
       <stdint.h> header.

Should probably stick with int and unsigned int...

Anthony Liguori
Linux/Active Directory Interoperability
Linux Technology Center (LTC) - IBM Austin
E-mail: aliguor at us.ibm.com
Phone: (512) 838-1208
Tie Line: 678-1208

On Sat, May 29, 2004 at 10:29:39AM +1000, Andrew Bartlett wrote:

> >  > any objections when I convert 'unsigned char' to uint8
> >  > in samba4
> >  >
> >  > and 'unsigned' and 'unsigned int' to uint_t.
> >
> > That's OK with me.
>
> Lets just make sure we don't take it too far - I don't want to see all
> our string becoming 'int8 *' ;-)

Agreed.  For example there is a big difference between signed and
unsigned char in some situations.  I think there is a bit of a precedent
for keeping char * and unsigned char * as they are a C idiom for working
with strings.

> Personally, I don't see the point in the short names for 'unsigned
> int'.  I understand the need for explicit 64 bit names in particular
> (where various compilers call it a different thing) but what exactly was
> wrong with 'unsigned int'?

Again, I think it's a bit of a C idiom to use int and unsigned int for
general use unless there is a pressing reason to use a fixed-width type
(e.g marshalling/unmarshalling from the wire or working with quantities
that have been taken from the wire).


Tim.


#### signature.asc has been removed from this note on June 02, 2004 by 
Anthony Liguori

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/octet-stream
Size: 197 bytes
Desc: not available
Url : http://lists.samba.org/archive/samba-technical/attachments/20040602/8594caaa/signature.obj


More information about the samba-technical mailing list