Possible problems in NAPI.C

F.A.Akeroyd at rl.ac.uk F.A.Akeroyd at rl.ac.uk
Mon Feb 21 17:39:29 GMT 2000


Ray,

i think that is probably caused by "int32" being defined as "long"
rather than as "int" on some systems (but always as a 32 bit sized value);
even if "long" and "int" are the same size, they are not classed as the same
type by the compiler and hence a warning is issued about (int*) being 
cast to (long*). We could remove the warning by putting an (int32*) cast on
the line; however i wonder if it would be better to change the definition of
NXputslab and NXgetslab to take "int32*" rather than "int*"? I don't think
it would
cause a problem for most people's code (at worse they would get the same
warning you
just had, but if the code worked before the change it would still work after
it)

Also, i wonder if the FORTRAN interface needs a look ... i believe it passes
INTEGER types to NXputslab etc, but if a C integer is 16bit is a FORTRAN
INTEGER also 16bit? If we changed the C interface to be "int32*" then
you could make things safe by forcing FORTRAN to send 32bit integers using
some modern
equivalent of "INTEGER*4" (is it selected_int_kind()?)

Regards,

Freddie 

--
Freddie Akeroyd                              Tel:  (01235) 445457
ISIS Facility                                    Fax: (01235) 445720
Rutherford Appleton Laboratory
Chilton, DIDCOT, OX11 OQX, GB      http://www.isis.rl.ac.uk/


-----Original Message-----
From: Ray Osborn [mailto:ROsborn at anl.gov]
Sent: 21 February 2000 17:04
To: NAPI
Subject: Possible problems in NAPI.C


Following the recent postings of int32-corrected versions of NAPI.C, I tried
to compile it on our Linux cluster using Absoft Pro Fortran (and C).  I've
been getting the following warnings:

napi.c: In function `nxiputslab':
napi.c:1136: warning: passing arg 2 of `SDwritedata' from incompatible
pointer type
napi.c:1136: warning: passing arg 4 of `SDwritedata' from incompatible
pointer type

This refers to the following lines :

       /* write directly */
       iRet = SDwritedata (pFile->iCurrentSDS,iStart,
              iStride, iSize, data);

which are invoked if sizeof(int) is 4 i.e. when a local copy is NOT made.

I'm guessing that the compiler is worried that there are two calls to
SDwritedata in this function, one passing int32 arrays and the other int's,
and hasn't worked out that they must be the same in this section of code.

Since I would prefer not to have any compiler warnings on our code, do you
have any recommendations for a fix?  Should we typecast the iStart and iSize
arrays even though it's unnecessary, or should we just copy all the arrays
whether the int size if 4 or not?

Any opinions?

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