From: Patrice D. <per...@fr...> - 2008-02-03 17:16:46
|
On Sun, Feb 03, 2008 at 10:36:51AM -0500, Arlindo da Silva wrote: > On Feb 3, 2008 9:57 AM, Brian Doty <do...@co...> wrote: > > > lengths in a GRIB msg are defined by the GRIB specification and are > > independent of systems definitions like g2int. It is appropriate to > > hardcode the length. Or to use a typedef that is dependent on the > > GRIB definitions (ie, hardcoded). It probably doesn't matter how > > long hdr is (as long as it is at least 4 bytes ) but you want to read > > exactly 4 bytes no more no less.. Brian > > > > > You and Jennifer are right. Do you think grib2c is robust enough to work on > machines where sizeof(int)!=4? If not, it may pay to add something to > configure.ac to detect such cases and stop with an error. > > Pat: do you know how to do this? There are indeed autoconf macros to test for a type length, AC_CHECK_SIZEOF, for example AC_CHECK_SIZEOF([uint8_t]) if test $ac_cv_sizeof_uint8_t -eq 1; then ... fi There are types of given length in #include <inttypes.h> like int32_t uint32_t int16_t and so on and so forth (it is in POSIX 99). In libdap, if inttypes.h is found and the size of the types are right, an include file based on inttypes.h is used. Otherwise types with the correct size are searched for and corresponding symbols are set in config.h. The main configure macro is in conf/acinclude.m4 in DODS_CHECK_SIZES. -- Pat |