Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add legacy macro option #3030

Merged
merged 8 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,11 @@ else()
set(NETCDF_ENABLE_HDF4 OFF)
endif()

# Option legacy macros
# Do we want to enable unsafe macros, e.g. _FillValue in addition to NC_FillValue.
# See https://github.com/Unidata/netcdf-c/issues/3029
option(NETCDF_ENABLE_LEGACY_MACROS "Enable legacy macros for backwards compatibility. Use with Caution." ON)

# Option Logging, only valid for netcdf4 dispatchers.
option(NETCDF_ENABLE_LOGGING "Enable Logging." OFF)
if(NOT NETCDF_ENABLE_NETCDF4)
Expand Down Expand Up @@ -662,14 +667,18 @@ if(ENABLE_PLUGIN_INSTALL)
set(NETCDF_PLUGIN_INSTALL_DIR "$ENV{HDF5_PLUGIN_PATH}")
else()
if(ISMSVC OR ISMINGW)
set(NETCDF_PLUGIN_INSTALL_DIR "$ENV{ALLUSERSPROFILE}\\hdf5\\lib\\plugin")
else()
set(NETCDF_PLUGIN_INSTALL_DIR "/usr/local/hdf5/lib/plugin")
endif()
endif()
message(STATUS "Defaulting to -DPLUGIN_INSTALL_DIR=${NETCDF_PLUGIN_INSTALL_DIR}")
set(NETCDF_PLUGIN_INSTALL_DIR "$ENV{ALLUSERSPROFILE}\\hdf5\\lib\\plugin")
else()
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(NETCDF_PLUGIN_INSTALL_DIR "/usr/local/hdf5/lib/plugin")
else()
set(NETCDF_PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/hdf5/lib/plugin")
endif(NOT DEFINED CMAKE_INSTALL_PREFIX)
endif(ISMSVC OR ISMINGW)
endif(DEFINED ENV{HDF5_PLUGIN_PATH})
message(STATUS "Defaulting to -DPLUGIN_INSTALL_DIR=${NETCDF_PLUGIN_INSTALL_DIR}")
endif()
endif()
endif(ENABLE_PLUGIN_INSTALL)

if(ENABLE_PLUGIN_INSTALL)
# Use the lowest priority dir in the path
Expand Down Expand Up @@ -1694,6 +1703,7 @@ is_enabled(NETCDF_ENABLE_PARALLEL4 HAS_PARALLEL4)
is_enabled(NETCDF_ENABLE_DAP HAS_DAP)
is_enabled(NETCDF_ENABLE_DAP2 HAS_DAP2)
is_enabled(NETCDF_ENABLE_DAP4 HAS_DAP4)
is_enabled(NETCDF_ENABLE_LEGACY_MACROS HAS_LEGACY_MACROS)
is_enabled(NETCDF_ENABLE_BYTERANGE HAS_BYTERANGE)
is_enabled(NETCDF_ENABLE_DISKLESS HAS_DISKLESS)
is_enabled(USE_MMAP HAS_MMAP)
Expand Down
4 changes: 3 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ This file contains a high-level description of this package's evolution. Release

## Known Issue

* Parallel operation using `mpich 4.2.0` (the default on `Ubuntu 24.04`) results in 'unexpected results' when running `nc_test4/run_par_test.sh`. This can be fixed by removing `mpich` and associated libraries and development packages and installing `mpich 4.2.2` by hand, or by using `openmpi` provided via `apt`.
> Parallel operation using `mpich 4.2.0` (the default on `Ubuntu 24.04`) results in 'unexpected results' when running `nc_test4/run_par_test.sh`. This can be fixed by removing `mpich` and associated libraries and development packages and installing `mpich 4.2.2` by hand, or by using `openmpi` provided via `apt`.

## Release Notes

### Release Candidate 2 - TBD

> Note: To avoid a conflict between `_FillValue` and `libc++18`, we have introduced a new option, `--enable-legacy-macros` for autotools and `NETCDF_ENABLE_LEGACY_MACROS` for cmake. These are turned on by default currently but will be turned off eventually. Developers are encouraged to move away from the `FillValue` macro and replace it with the new `NC_FillValue` macro. See [Github #2858](https://github.com/Unidata/netcdf-c/issues/2858) for more information.

* Provide better documentation for the .rc file mechanism and API. See [Github #2956](https://github.com/Unidata/netcdf-c/pull/2956) for more information.
* Convert NCZarr V2 to store all netcdf-4 specific info as attributes. This improves interoperability with other Zarr implementations by no longer using non-standard keys. The price to be paid is that lazy attribute reading cannot be supported. See [Github #2836](https://github.com/Unidata/netcdf-c/pull/2936) for more information.
* Cleanup the option code for NETCDF_ENABLE_SET_LOG_LEVEL\[_FUNC\] See [Github #2931](https://github.com/Unidata/netcdf-c/pull/2931) for more information.
Expand Down
3 changes: 3 additions & 0 deletions config.h.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,9 @@ with zip */
/* Idspatch table version */
#cmakedefine NC_DISPATCH_VERSION ${NC_DISPATCH_VERSION}

/* Enable Legacy, potential-conflict Macro _FillValue */
#cmakedefine NETCDF_ENABLE_LEGACY_MACROS

/* no IEEE float on this platform */
#cmakedefine NO_IEEE_FLOAT 1

Expand Down
24 changes: 22 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,19 @@ else
enable_set_log_level=no
fi

# Do we want to enable unsafe macros, e.g. _FillValue in addition to NC_FillValue.
# See https://github.com/Unidata/netcdf-c/issues/3029
AC_MSG_CHECKING([whether to allow legacy macros])
AC_ARG_ENABLE([legacy-macros],
[AS_HELP_STRING([--disable-legacy-macros],
[enable legacy macros for backwards compatibility purposes. Use with caution.\
This can lead to unexpected consequences/behavior.])])
test "x$enable_legacy_macros" = xno || enable_legacy_macros=yes
AC_MSG_RESULT($enable_legacy_macros)
if test "x$enable_legacy_macros" = xyes; then
AC_DEFINE([NETCDF_ENABLE_LEGACY_MACROS], 1, [If true, enable legacy macros in netcdf.h])
fi

# Does the user want to allow reading of remote data via range headers?
AC_MSG_CHECKING([whether byte range support is enabled])
AC_ARG_ENABLE([byterange],
Expand Down Expand Up @@ -1932,6 +1945,7 @@ AM_CONDITIONAL(USE_DAP, [test "x$enable_dap" = xyes]) # Alias
# Provide protocol specific flags
AM_CONDITIONAL(NETCDF_ENABLE_DAP, [test "x$enable_dap" = xyes])
AM_CONDITIONAL(NETCDF_ENABLE_DAP4, [test "x$enable_dap4" = xyes])
AM_CONDITIONAL(NETCDF_ENABLE_LEGACY_MACROS, [test "x$netcdf_enable_legacy_macros" = xyes])
AM_CONDITIONAL(USE_STRICT_NULL_BYTE_HEADER_PADDING, [test x$enable_strict_null_byte_header_padding = xyes])
AM_CONDITIONAL(NETCDF_ENABLE_CDF5, [test "x$enable_cdf5" = xyes])
AM_CONDITIONAL(NETCDF_ENABLE_DAP_REMOTE_TESTS, [test "x$enable_dap_remote_tests" = xyes])
Expand Down Expand Up @@ -2050,6 +2064,7 @@ AC_SUBST(NC_LIBS,[$NC_LIBS])
AC_SUBST(HAS_DAP,[$enable_dap])
AC_SUBST(HAS_DAP2,[$enable_dap])
AC_SUBST(HAS_DAP4,[$enable_dap4])
AC_SUBST(HAS_LEGACY_MACROS,[$enable_legacy_macros])
AC_SUBST(HAS_NC2,[$nc_build_v2])
AC_SUBST(HAS_CDF5,[$enable_cdf5])
AC_SUBST(HAS_HDF4,[$enable_hdf4])
Expand Down Expand Up @@ -2156,8 +2171,13 @@ elif test "x$with_plugin_dir" = xyes ; then # --with-plugin-dir, no argument
if test "x$ISMSVC" = xyes || test "x$ISMINGW" = xyes; then
PLUGIN_PATH="${ALLUSERSPROFILE}\\hdfd5\\lib\\plugin"
else
PLUGIN_PATH="/usr/local/hdf5/lib/plugin"
fi
if test "x${prefix}" = xNONE ; then
PLUGIN_PATH="/usr/local/hdf5/lib/plugin"
else
PLUGIN_PATH="${prefix}/hdf5/lib/plugin"
fi

fi
fi
# Use the lowest priority dir in the path
if test "x$ISMSVC" = xyes || test "x$ISMINGW" = xyes; then
Expand Down
10 changes: 9 additions & 1 deletion include/netcdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,15 @@ extern "C" {
* different value than the above defaults, create an attribute with
* the same type as the variable and this reserved name. The value you
* give the attribute will be used as the fill value for that
* variable. */
* variable.
* Refactored to NC_FillValue in support of
* https://github.com/Unidata/netcdf-c/issues/2858, and parameterized
* behind an unsafe macros option as part of
* https://github.com/Unidata/netcdf-c/issues/3029
*/
#ifdef NETCDF_ENABLE_LEGACY_MACROS
#define _FillValue "_FillValue"
#endif
#define NC_FillValue "_FillValue"
#define NC_FILL 0 /**< Argument to nc_set_fill() to clear NC_NOFILL */
#define NC_NOFILL 0x100 /**< Argument to nc_set_fill() to turn off filling of data. */
Expand Down
1 change: 1 addition & 0 deletions libnetcdf.settings.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Shared Library: @enable_shared@
Static Library: @enable_static@
Extra libraries: @LIBS@
XML Parser: @XMLPARSER@
Legacy Macros: @HAS_LEGACY_MACROS@

# Features
--------
Expand Down
2 changes: 1 addition & 1 deletion plugins/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ AM_LDFLAGS += -module -avoid-version -shared -export-dynamic $(NOUNDEFINED)
# Create an alternate directory if not installing.
ALTPLUGINDIR = ${abs_top_builddir}/plugins/plugindir

RPATH = -rpath $(abs_builddir)/.libs
RPATH = -rpath $(abs_top_builddir)/.libs

# This is where the plugins are to be installed
if ENABLE_PLUGIN_DIR
Expand Down
Loading