Re: [netcdfgroup] Files with compound types ARE portable!

  • To: Jeff Whitaker <jswhit@xxxxxxxxxxx>
  • Subject: Re: [netcdfgroup] Files with compound types ARE portable!
  • From: Ed Hartnett <ed@xxxxxxxxxxxxxxxx>
  • Date: Wed, 27 May 2009 14:31:49 -0600
Jeff Whitaker <jswhit@xxxxxxxxxxx> writes:

>      int ncid, typeid, varid, dimid, retval;
>      char name[NC_MAX_NAME + 1];
>      int dimids[] = {0};
>
>      struct s1
>      {
>        short i;
>        long long j;
>      /*};*/
>      } __attribute__ ((__packed__));
>

Howdy Jeff!

Your trouble is in your use of __attribute__ ((__packed__)).

This changes the packing of C structs, and that will not work, because
HDF5 has already figured out how your C compiler packs structs, and if
you change it, the HDF5 layer will become very confused.

If you wish to change the packing of structs by your C compiler, you
must do so with CFLAGS, and you must use the same CFLAGS when building
HDF5, then you must also use the same CFLAGS when building netCDF, and
the same CFLAGS whenever you compile user programs with compound types.

Without the "__attribute__ ((__packed__)) " this example works just
fine. In fact, I have incorporated it into libsrc4/tst_compounds.c.

Thanks,

Ed

-- 
Ed Hartnett  -- ed@xxxxxxxxxxxxxxxx



  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: