What to do about int's

Mark Koennecke Mark.Koennecke at psi.ch
Mon Feb 14 15:49:12 GMT 2000




On Mon, 14 Feb 2000, Ray Osborn wrote:

> 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?

  The problem here that we are typecasting an array which in C is
  identical to a pointer. Now, if you have an array which is 16-bit int
  and you access it through a typecasted pointer as 32-bit int you read
  16 bit two values for one 32 bit. This usually does not lead to the
  desired result. Typecasting a single 16-bit int to 32-bit int usually
  works and if not you should complain to your compiler vendor.
 
> 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.

  see above.

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

  Well, 16-bit int is dying but may be we get 64-bit int some day
  soon..... But as 16 bit is rare and Brian seems to have solved his
  problem I do not think that we need to hurry. 

> 
> 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.

  I think your idea of doing the necessary typecasts within the NAPI 
  functions is the right solution.  

> 
> 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.

  Responded! 

                          Mark




More information about the NeXus-developers mailing list