Re: a C programming question for you all: using H5Sselect_elements without a cast?

NOTE: The netcdf-hdf mailing list is no longer active. The list archives are made available for historical reasons.

  • To: Ed Hartnett <ed@xxxxxxxxxxxxxxxx>
  • Subject: Re: a C programming question for you all: using H5Sselect_elements without a cast?
  • From: Russ Rew <russ@xxxxxxxxxxxxxxxx>
  • Date: Thu, 20 Nov 2003 10:03:53 -0700
Ed,

> Here's a C programming question. There is a function:
> 
>     herr_t H5Sselect_elements(hid_t space_id, H5S_seloper_t op, const size_t 
> num_elements, const hssize_t *coord[ ] ) 
> 
> If I try this, for accessing one element of a one-dimensional array:
> 
>           hssize_t coord[1][1]
>           coord[0][0] = attnum;
>           if (H5Sselect_elements(att_info_spaceid, H5S_SELECT_SET, 
>                                  1, coord) < 0)
> 
> The compiler whines at me:
> 
> nc4hdf.c:446: warning: passing arg 4 of `H5Sselect_elements' from 
> incompatible pointer type
> 
> So how the heck can I call this thing without a warning?

Here's one way:

            const hssize_t coord[1][1]
            coord[0][0] = attnum;
            if (H5Sselect_elements(att_info_spaceid, H5S_SELECT_SET, 
                                   1, coord[0]) < 0)

but you had to stick a "const" in the declaration to make that work.
Without the const, you will get a warning, since you're passing in
something that is not const correct.

--Russ

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