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: Thu, 28 May 2009 04:41:02 -0600
Jeff Whitaker <jswhit@xxxxxxxxxxx> writes:

> Concerning packing of structs, one of us is very confused about how
> HDF5 compound types work (and it's probably me). I thought that you
> could specify arbitrary offsets that do not necessarily correspond to
> the default alignment of your C compiler, and HDF5 would take care of
> everything when you read the data back in.  

No, sorry, this turns out not to be the case.

> Otherwise, how would you
> read a file created with HDF5 on a platform with a different default
> alignment than the one it was written on?  Isn't the whole point of
> the HDF5 layer that you don't have worry about the default alignment
> of structs for the C compiler?

HDF5 can handle it, but not if you change the alignment of your struct
with a compiler directive!

HDF5 figures out packing when it is built on your machine, in the HDF5
configure script. Using any other packing than the one HDF5 figured out
at its build time will result in confusion.

So if you want a different packing of your struct, you must specify the
packing options you want with compiler flags, and make sure you use
those flags when building HDF5 (and netCDF-4, and your own program).

I have forwarded your question to the HDF5 team to ensure that I am
telling you the correct answer, and to see if they can help explain this
any more clearly.

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: