Back Midas Rome Roody Rootana
  Root Display GUI  Not logged in ELOG logo
Entry  16 Nov 2007, John M O'Donnell, Bug Fix, uint32_t or UInt_t DataSourceTNetFolder.h
    Reply  16 Nov 2007, Konstantin Olchanski, Bug Fix, uint32_t or UInt_t 
       Reply  19 Nov 2007, John M O'Donnell, Bug Fix, uint32_t or UInt_t 
Message ID: 132     Entry time: 19 Nov 2007     In reply to: 131
Author: John M O'Donnell 
Topic: Bug Fix 
Subject: uint32_t or UInt_t 
I'm using Redhat workstation with:
  gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
  ROOT version 5.16/00

it is unlikely that UInt_t will ever be too small.  If it is too small, then ROOT will
break!  It is clearly intended to be 32 bits long.  From Rtypes.h:

#ifdef R__INT16
typedef long           Int_t;       //Signed integer 4 bytes
typedef unsigned long  UInt_t;      //Unsigned integer 4 bytes
#else
typedef int            Int_t;       //Signed integer 4 bytes (int)
typedef unsigned int   UInt_t;      //Unsigned integer 4 bytes (unsigned int)
#endif

Of course, stdint.h is defined in a standard.  However ROOT doesn't really try to follow
the standard (CINT compiles a language similar to C++, but not exactly C++), and indeed
the file stdint.h is not explicitly included in any of $ROOTSYS/include/*.h.

John.

> > I just downloaded and compiled the latest tarball.
> > 
> > line 98 of DataSourceTNetFolder.h complained about unit32_t.  While I could have
> > added an include to make this work, I instead changed it to use the ROOT type
> > UInt_t.
> 
> Uint_t is technically incorrect. The data returned from the socket connection is a
> 32-bit pointer to an object in the remote process (how do they come up with
> communication protocols like this?!?). The type "Uint_t" is not defined to be of any
> particular size and is not necessarily big enough to hold a 32-bit unsigned integer.
> 
> According to the "C99" standard, the correct C data type for 32-bit unsigned
> integers is uint32_t, defined in "#include <stdint.h>", e.g. see
> http://www.oreillynet.com/pub/a/network/2003/10/07/michael_barr.html
> 
> I have now added the missing "#include <stdint.h>" statement to
> DataSourceTNetFolder.h, commited as revision 230.
> 
> I am puzzled why the code compiled without this include statement, possibly on my
> SL4.3 machine with ROOT v5.16.00, some ROOT or system header file included it for
> me. I am curious what system you use where this code failed to compile?
> 
> K.O.
ELOG V3.1.4-2e1708b5