What to do about int's

F.A.Akeroyd at rl.ac.uk F.A.Akeroyd at rl.ac.uk
Mon Feb 14 15:58:07 GMT 2000


Hi Ray,

(1) If you convert a 16bit integer to a 32 bit integer by assignment, there
is
    no problem. However, the conversion here was by casting a pointer which
is
    equivalent to doing a FORTRAN equivalence. Hence 16bits of "junk" after
    the real value was being read.

(2) It is "allowed", but whether it is valid depends on what your program
does
    with it!  If you cast scalar arguments, it will always work; casting
arrays
    is more dubious

(3) As well as 16 bit ints i can see 64bit ints being a problem in the not 
    too distant future

(4) There is no need to cast anything passed by value ... it will be done
for you
    automatically. As "int" is "int32" on almost all platforms, we could
probably
    just put "int32*" in the appropriate places and nobody would really
notice.
    Or maybe we should define NXint32? Alternatively, we could leave the
prototype
    as "int*", but put our own code in with "#ifdef" on "sizeof(int)".

Freddie

--
Freddie Akeroyd
ISIS Facility
Rutherford Appleton Laboratory
Chilton, DIDCOT, OX11 OQX, GB


-----Original Message-----
From: Ray Osborn [mailto:ROsborn at anl.gov]
Sent: 14 February 2000 15:29
To: napi at anl.gov
Subject: What to do about int's


I would like some technical views from the NAPI team of the recent debate 
about int's.  Although I've made some progress in learning C, I realize that
I only know some things skin deep.  I'm sure you could clear up the
following points:

1) Is Brian Tieman right that typecasting could have added high-order bits
when calling the HDF routines?  I would have thought that converting an
integer from one length to another should be a standard typecast operation.
If he's not right, is the cause of the bug something else?

2) Is it valid to typecast array arguments in a function call, or does it
only work on scalar values?  I can understand how you can copy a value of
one type into one of another type, but it's less obvious how you pass an
array address, and expect the called routine to convert each of the array
values.

3) Do people agree with my comment last week that it is necessary to support
16-bit int's?

4) If so, what should our policy be?  It shouldn't take long to clear things
up in NAPI.C.  What we do depends on the answer to the above questions.  For
example, we could typecast scalars (passed by value) to HDF calls, but copy
all the rest into local int32 variables.  I certainly don't believe that we
should suddenly ask everyone who uses NAPI to rewrite their programs
converting all int's to int32's, unless someone can convince me it's really
necessary.

Please respond as soon as you can.  We must be able to act promptly to clear
up bugs when they are discovered, since more and more people are starting to
use the NeXus API.

Thanks,
Ray
--
Dr Ray Osborn                Tel: +1 (630) 252-9011
Materials Science Division   Fax: +1 (630) 252-7777
Argonne National Laboratory  E-mail: ROsborn at anl.gov
Argonne, IL 60439-4845



More information about the NeXus-developers mailing list