Skip to content

Commit 73b9f18

Browse files
authored
Merge pull request #2911 from WardF/refactor_fillvalue_macro.wif
2 parents fc02ef4 + 2b0b18b commit 73b9f18

19 files changed

Lines changed: 54 additions & 53 deletions

File tree

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This file contains a high-level description of this package's evolution. Release
77

88
## 4.9.3 - TBD
99

10+
* Refactor macro `_FillValue` to `NC_FillValue` to avoid conflict with libc++ headers. See [Github #2858](https://github.com/Unidata/netcdf-c/issues/2858) for more information.
1011
* Changed `cmake` build options to be prefaced with `NETCDF`, to bring things in to line with best practices. This will permit a number of overall quality of life improvements to netCDF, in terms of allowing it to be more easily integrated with upstream projects via `FetchContent()`, `subdirectory()`, etc. Currently, the naming convention in use thus far will still work, but will result in warning messages about deprecation, and instructions on how to update your workflow. See [Github #2895](https://github.com/Unidata/netcdf-c/pull/2895) for more information.
1112
* Fix some problems in handling S3 urls with missing regions. See [Github #2819](https://github.com/Unidata/netcdf-c/pull/2819).
1213
* Incorporate a more modern look and feel to user documentation generated by Doxygen. See [Doxygen Awesome CSS](https://github.com/jothepro/doxygen-awesome-css) and [Github #2864](https://github.com/Unidata/netcdf-c/pull/2864) for more information.

include/netcdf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ extern "C" {
110110
* the same type as the variable and this reserved name. The value you
111111
* give the attribute will be used as the fill value for that
112112
* variable. */
113-
#define _FillValue "_FillValue"
113+
#define NC_FillValue "_FillValue"
114114
#define NC_FILL 0 /**< Argument to nc_set_fill() to clear NC_NOFILL */
115115
#define NC_NOFILL 0x100 /**< Argument to nc_set_fill() to turn off filling of data. */
116116

libhdf5/hdf5attr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ nc4_put_att(NC_GRP_INFO_T* grp, int varid, const char *name, nc_type file_type,
564564
* Since fill mismatch is no longer required, we need to convert the
565565
* att's type to the vars's type as part of storing.
566566
*/
567-
if (!strcmp(att->hdr.name, _FillValue) && varid != NC_GLOBAL)
567+
if (!strcmp(att->hdr.name, NC_FillValue) && varid != NC_GLOBAL)
568568
{
569569
/* Fill value must have exactly one value */
570570
if (len != 1)

libhdf5/hdf5var.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -673,17 +673,17 @@ nc_def_var_extra(int ncid, int varid, int *shuffle, int *unused1,
673673
var->hdr.name));
674674

675675
/* If there's a _FillValue attribute, delete it. */
676-
retval = NC4_HDF5_del_att(ncid, varid, _FillValue);
676+
retval = NC4_HDF5_del_att(ncid, varid, NC_FillValue);
677677
if (retval && retval != NC_ENOTATT)
678678
return retval;
679679

680680
/* Create a _FillValue attribute; will also fill in var->fill_value */
681-
if ((retval = nc_put_att(ncid, varid, _FillValue, var->type_info->hdr.id,
681+
if ((retval = nc_put_att(ncid, varid, NC_FillValue, var->type_info->hdr.id,
682682
1, fill_value)))
683683
return retval;
684684
} else if (var->fill_value && no_fill && (*no_fill)) { /* Turning off fill value? */
685685
/* If there's a _FillValue attribute, delete it. */
686-
retval = NC4_HDF5_del_att(ncid, varid, _FillValue);
686+
retval = NC4_HDF5_del_att(ncid, varid, NC_FillValue);
687687
if (retval && retval != NC_ENOTATT) return retval;
688688
if((retval = NC_reclaim_data_all(h5->controller,var->type_info->hdr.id,var->fill_value,1))) return retval;
689689
var->fill_value = NULL;

libnczarr/zattr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ ncz_put_att(NC_GRP_INFO_T* grp, int varid, const char *name, nc_type file_type,
581581
* copy the value to the fill_value pointer of the NC_VAR_INFO_T
582582
* struct for this var. (But ignore a global _FillValue
583583
* attribute). Also kill the cache fillchunk as no longer valid */
584-
if (!strcmp(att->hdr.name, _FillValue) && varid != NC_GLOBAL)
584+
if (!strcmp(att->hdr.name, NC_FillValue) && varid != NC_GLOBAL)
585585
{
586586
/* Fill value must have exactly one value */
587587
if (len != 1)
@@ -991,12 +991,12 @@ ncz_create_fillvalue(NC_VAR_INFO_T* var)
991991
/* Make sure _FillValue does not exist */
992992
for(i=0;i<ncindexsize(var->att);i++) {
993993
fv = (NC_ATT_INFO_T*)ncindexith(var->att,i);
994-
if(strcmp(fv->hdr.name,_FillValue)==0) break;
994+
if(strcmp(fv->hdr.name,NC_FillValue)==0) break;
995995
fv = NULL;
996996
}
997997
if(fv == NULL) {
998998
/* Create it */
999-
if((stat = ncz_makeattr((NC_OBJ*)var,var->att,_FillValue,var->type_info->hdr.id,1,var->fill_value,&fv)))
999+
if((stat = ncz_makeattr((NC_OBJ*)var,var->att,NC_FillValue,var->type_info->hdr.id,1,var->fill_value,&fv)))
10001000
goto done;
10011001
}
10021002
}

libnczarr/zvar.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -727,19 +727,19 @@ ncz_def_var_extra(int ncid, int varid, int *shuffle, int *unused1,
727727
var->hdr.name));
728728

729729
/* If there's a _FillValue attribute, delete it. */
730-
retval = NCZ_del_att(ncid, varid, _FillValue);
730+
retval = NCZ_del_att(ncid, varid, NC_FillValue);
731731
if (retval && retval != NC_ENOTATT)
732732
goto done;
733733

734734
/* Create a _FillValue attribute; will also fill in var->fill_value */
735-
if ((retval = nc_put_att(ncid, varid, _FillValue, var->type_info->hdr.id,
735+
if ((retval = nc_put_att(ncid, varid, NC_FillValue, var->type_info->hdr.id,
736736
1, fill_value)))
737737
goto done;
738738
/* Reclaim any existing fill_chunk */
739739
if((retval = NCZ_reclaim_fill_chunk(zvar->cache))) goto done;
740740
} else if (var->fill_value && no_fill && (*no_fill)) { /* Turning off fill value? */
741741
/* If there's a _FillValue attribute, delete it. */
742-
retval = NCZ_del_att(ncid, varid, _FillValue);
742+
retval = NCZ_del_att(ncid, varid, NC_FillValue);
743743
if (retval && retval != NC_ENOTATT) return retval;
744744
if((retval = NCZ_reclaim_fill_value(var))) return retval;
745745
}

libsrc/nc3internal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,7 @@ NC3_inq_var_fill(const NC_var *varp, void *fill_value)
17261726
/*
17271727
* find fill value
17281728
*/
1729-
attrpp = NC_findattr(&varp->attrs, _FillValue);
1729+
attrpp = NC_findattr(&varp->attrs, NC_FillValue);
17301730
if ( attrpp != NULL ) {
17311731
const void *xp;
17321732
/* User defined fill value */

libsrc/putget.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ fill_NC_var(NC3_INFO* ncp, const NC_var *varp, long long varsize, size_t recno)
156156
/*
157157
* Set up fill value
158158
*/
159-
attrpp = NC_findattr(&varp->attrs, _FillValue);
159+
attrpp = NC_findattr(&varp->attrs, NC_FillValue);
160160
if( attrpp != NULL )
161161
{
162162
/* User defined fill value */

libsrc/var.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ NC3_inq_var(int ncid,
720720
if (no_fillp != NULL) *no_fillp = varp->no_fill;
721721

722722
if (fill_valuep != NULL) {
723-
status = nc_get_att(ncid, varid, _FillValue, fill_valuep);
723+
status = nc_get_att(ncid, varid, NC_FillValue, fill_valuep);
724724
if (status != NC_NOERR && status != NC_ENOTATT)
725725
return status;
726726
if (status == NC_ENOTATT) {
@@ -854,12 +854,12 @@ NC3_def_var_fill(int ncid,
854854
if (fill_value != NULL && !varp->no_fill) {
855855

856856
/* If there's a _FillValue attribute, delete it. */
857-
status = NC3_del_att(ncid, varid, _FillValue);
857+
status = NC3_del_att(ncid, varid, NC_FillValue);
858858
if (status != NC_NOERR && status != NC_ENOTATT)
859859
return status;
860860

861861
/* Create/overwrite attribute _FillValue */
862-
status = NC3_put_att(ncid, varid, _FillValue, varp->type, 1, fill_value, varp->type);
862+
status = NC3_put_att(ncid, varid, NC_FillValue, varp->type, 1, fill_value, varp->type);
863863
if (status != NC_NOERR) return status;
864864
}
865865

nc_test/t_nc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static const char * const reqattr[] = {
147147
"SCALEMIN",
148148
"SCALEMAX",
149149
"FIELDNAM",
150-
_FillValue
150+
NC_FillValue
151151
};
152152
#define NUM_RATTRS 6
153153

@@ -399,9 +399,9 @@ main(int argc, char *argv[])
399399
{
400400
int ifill = -1; double dfill = -9999;
401401
assert( nc_put_att_int(id, Long_id,
402-
_FillValue, NC_INT, 1, &ifill) == NC_NOERR);
402+
NC_FillValue, NC_INT, 1, &ifill) == NC_NOERR);
403403
assert( nc_put_att_double(id, Double_id,
404-
_FillValue, NC_DOUBLE, 1, &dfill) == NC_NOERR);
404+
NC_FillValue, NC_DOUBLE, 1, &dfill) == NC_NOERR);
405405
}
406406

407407
#ifdef REDEF

0 commit comments

Comments
 (0)