This document, “API Compatibility Macros in HDF5,” introduces the approach taken by The HDF Group in HDF Release 1.8.0 to help existing users of HDF5 address compatibility issues in the HDF5 API. The companion document, New Features in HDF5 Release 1.8.0 and Format Compatibility Considerations, discusses features introduced in HDF5 Release 1.8.0, the HDF5 API calls associated with those features, and the potential file format compatibility issues that may result if the new features are used.
HDF5 Release 1.8.0 includes a number of new features that will offer many users of HDF5 substantial performance improvements and expanded capabilities. Many of these features can only be accessed via revised API calls. Given the scope of the changes, and recognizing the potentially time-consuming task of editing all the affected calls in user applications, The HDF Group has created a set of macros that can be used to flexibly and easily map existing API calls to either 1.6.x or 1.8.x (currently 1.8.0) functions. We refer to these as the API compatibility macros.
The HDF Group generally encourages users to update applications to work with the latest HDF5 library release, so that all new features and enhancements are available to them. At the same time, The HDF Group understands that under some circumstances updating applications may not be feasible or necessary. The API compatibility macros, described in this document, provide a bridge from old APIs to new, and can be particularly helpful in situations such as these:
Concretely, consider the function H5Acreate
in HDF5 releases prior
to 1.8.0:
hid_t H5Acreate( hid_t loc_id,
const char *attr_name,
hid_t type_id,
hid_t space_id,
hid_t acpl_id )
hid_t H5Acreate2( hid_t loc_id,
const char *attr_name,
hid_t type_id,
hid_t space_id,
hid_t acpl_id,
hid_t aapl_id )
hid_t H5Acreate1( hid_t loc_id,
const char *attr_name,
hid_t type_id,
hid_t space_id,
hid_t acpl_id )
H5Acreate
H5Acreate
, will be mapped to either
H5Acreate1
or H5Acreate2
.
The mapping is determined by a combination of the
configuration options use to build the HDF5 Library
and compile-time options used to build the application.
The calling parameters used with the H5Acreate
compatibility macro should match the number and type of the
function they will be mapped to
(H5Acreate1
or H5Acreate2
).
The function names ending in "1" or "2" are referred to as version-numbered names, and the corresponding functions are referred to as version-numbered functions. For new code development, The HDF Group recommends use of the compatibility macro mapped to the latest version of the function. The original versions of these functions, with names ending in "1", should be considered deprecated and, in general, should not be used when developing new code.
Compatibility Macro Mapping Options
To determine the mapping for a given API compatibility macro in a given application, a combination of user-controlled selections, collectively referred to as the compatibility macro mapping options, is considered in the following sequence:
The tables that follow summarize the macro mapping behaviors, and the
configuration and compile-time options that control the mappings.
The macro H5Gcreate
is used to demonstrate mapping behavior.
Regardless of the macro mapping options used,
the 1.8.x functions will always be available
by explicitly calling the version-numbered functions
by their version-numbered names.
For example, H5Gcreate2
.
Through the compatibility macro mapping options provided, it is possible to
disallow calls to the deprecated 1.6.x functions,
such as H5Gcreate1
.
This capability can be used to guarantee only the
most recent versions of the functions are being called.
Library Mapping Options
When the HDF5 Library is built, configure
flags can be
used to control the API compatibility macro mapping behavior
exhibited by the library. This behavior can be overridden by application
and function mappings. One configure flag excludes deprecated functions
from the HDF5 library, making them unavailable to applications linked with
the library.
configure flag
|
Macros map to release
(version-numbered function; H5Gcreate shown)
|
Deprecated functions available?
( H5Gcreate1 )
|
---|---|---|
--with-default-api-version=v18
Also, default behavior if no flag specified. |
1.8.x
( H5Gcreate2 )
| yes |
--with-default-api-version=v16
|
1.6.x
( H5Gcreate1 )
| yes |
--disable-deprecated-symbols
|
1.8.x
( H5Gcreate2 )
| no |
Refer to the file libhdf5.settings
in the directory where
the HDF5 library is installed to determine the configure
flags used to build the library.
In particular, look for the two lines shown here:
Default Version of Public Symbols: v18
With Deprecated Public Symbols: Yes
Application Mapping Options
When an application using HDF5 APIs is built and linked with the HDF5 Library,
compile-time options to h5cc
can be
used to control the API compatibility macro mapping behavior
exhibited by the application.
The application mapping overrides the behavior specified by the library mapping,
and can be overridden on a function-by-function basis by the function mappings.
If the HDF5 Library was configured with the --disable-deprecated-symbols
flag, then the deprecated functions will not be available, regardless of the
application mapping options.
h5cc option
|
Macros map to release
(version-numbered function; H5Gcreate shown)
|
Deprecated functions available?
( H5Gcreate1 )
|
---|---|---|
Default behavior if no option specified. |
1.8.x
( H5Gcreate2 )
|
yes*
*if available in library |
-DH5_USE_16_API
|
1.6.x
( H5Gcreate1 )
|
yes*
*if available in library |
-DH5_NO_DEPRECATED_SYMBOLS
|
1.8.x
( H5Gcreate2 )
| no |
Function Mapping Options
Function mappings are specified when the application is built. These mappings can be used to control the mapping of the API compatibility macros to underlying functions on a function-by-function basis. The function mappings override the library and application mappings discussed earlier.
If the HDF5 Library was configured with the
--disable-deprecated-symbols
flag,
or -DH5_NO_DEPRECATED_SYMBOLS
is used to compile the application,
then the deprecated functions will not be available, regardless of the
function mapping options.
For every function with multiple available versions, a compile-time
version flag can be defined to selectively map the function macro
to the desired version-numbered function.
For example, the H5Gcreate
can be mapped to either H5Gcreate1
or
H5Gcreate2
.
When used, the value of the
H5Gcreate_vers
compile-time version flag determines
which function will be called:
H5Gcreate_vers
is set to 1
,
the macro H5Gcreate
will be mapped to
H5Gcreate1
.
h5cc ... -DH5Gcreate_vers=1 ...
H5Gcreate_vers
is set to 2
,
the macro H5Gcreate
will be mapped to
H5Gcreate2
.
h5cc ... -DH5Gcreate_vers=2 ...
H5Gcreate_vers
is not set,
the macro H5Gcreate
will be mapped to
either
H5Gcreate1
or
H5Gcreate2
,
based on the application mapping, if one was specified,
or on the library mapping.
h5cc ...
As of Release 1.8.0, the API compatibility macros, the function mapping compile-time version flags and values, and the corresponding version-numbered functions are as indicated:
Macro |
h5cc version flag and value
| Mapped To function |
---|---|---|
H5Acreate
| -DH5Acreate_vers=1
| H5Acreate1
|
-DH5Acreate_vers=2
| H5Acreate2
| |
H5Aiterate
| -DH5Aiterate_vers=1
| H5Aiterate1
|
-DH5Aiterate_vers=2
| H5Aiterate2
| |
H5Dcreate
| -DH5Dcreate_vers=1
| H5Dcreate1
|
-DH5Dcreate_vers=2
| H5Dcreate2
| |
H5Dopen
| -DH5Dopen_vers=1
| H5Dopen1
|
-DH5Dopen_vers=2
| H5Dopen2
| |
H5Eclear
| -DH5Eclear_vers=1
| H5Eclear1
|
-DH5Eclear_vers=2
| H5Eclear2
| |
H5Eprint
| -DH5Eprint_vers=1
| H5Eprint1
|
-DH5Eprint_vers=2
| H5Eprint2
| |
H5Epush
| -DH5Epush_vers=1
| H5Epush1
|
-DH5Epush_vers=2
| H5Epush2
| |
H5Eset_auto
| -DH5Eset_auto_vers=1
| H5Eset_auto1
|
-DH5Eset_auto_vers=2
| H5Eset_auto2
| |
H5Eget_auto
| -DH5Eget_auto_vers=1
| H5Eget_auto1
|
-DH5Eget_auto_vers=2
| H5Eget_auto2
| |
H5Ewalk
| -DH5Ewalk_vers=1
| H5Ewalk1
|
-DH5Ewalk_vers=2
| H5Ewalk2
| |
H5Gcreate
| -DH5Gcreate_vers=1
| H5Gcreate1
|
-DH5Gcreate_vers=2
| H5Gcreate2
| |
H5Gopen
| -DH5Gopen_vers=1
| H5Gopen1
|
-DH5Gopen_vers=2
| H5Gopen2
| |
H5Pget_filter
| -DH5Pget_filter_vers=1
| H5Pget_filter1
|
-DH5Pget_filter_vers=2
| H5Pget_filter2
| |
H5Pget_filter_by_id
| -DH5Pget_filter_by_id_vers=1
| H5Pget_filter_by_id1
|
-DH5Pget_filter_by_id_vers=2
| H5Pget_filter_by_id2
| |
H5Pinsert
| -DH5Pinsert_vers=1
| H5Pinsert1
|
-DH5Pinsert_vers=2
| H5Pinsert2
| |
H5Pregister
| -DH5Pregister_vers=1
| H5Pregister1
|
-DH5Pregister_vers=2
| H5Pregister2
| |
H5Rget_obj_type
| -DH5Rget_obj_typevers=1
| H5Rget_obj_type1
|
-DH5Rget_obj_type_vers=2
| H5Rget_obj_type2
| |
H5Tarray_create
| -DH5Tarray_create_vers=1
| H5Tarray_create1
|
-DH5Tarray_create_vers=2
| H5Tarray_create2
| |
H5Tcommit
| -DH5Tcommit_vers=1
| H5Tcommit1
|
-DH5Tcommit_vers=2
| H5Tcommit2
| |
H5Tget_array_dims
| -DH5Tget_array_dims_vers=1
| H5Tget_array_dims1
|
-DH5Tget_array_dims_vers=2
| H5Tget_array_dims2
| |
H5Topen
| -DH5Topen_vers=1
| H5Topen1
|
-DH5Topen_vers=2
| H5Topen2
|
See the HDF5 Reference Manual for complete descriptions of all API compatibility macros and version-numbered functions shown in Table 3.
It is possible to specify multiple function mappings for a single application build:
h5cc ... -DH5Gcreate_vers=1 -DH5Dcreate_vers=2...
The function mappings can be used to guarantee that a given API compatibility macro will be mapped to the desired underlying function version regardless of the library or application mappings. In cases where an application may benefit greatly from features offered by some of the later APIs, or must continue to use some earlier API versions for compatibility reasons, this fine-grained control may be very important.
As noted earlier, the function mappings can only reference version-numbered
functions that are included in the HDF5 library,
as determined by the configure flag used to build the library.
For example, if the HDF5 library being linked with the application was built
with the --disable-deprecated-symbols
option, version 1 of the
underlying functions would not be available, and the example above
that defined H5Gcreate_ver=1
would not be supported.
The function mappings do not negate any available functions.
If H5Gcreate1
is available in the installed version of the
HDF5 Library,
and the application was not compiled with the
-DH5_NO_DEPRECATED_SYMBOLS
flag,
the function H5Gcreate1
will remain available to
the application through its version-numbered name.
Similarly, H5Gcreate2
will remain available to the
application as H5Gcreate2
.
The function mapping version flag H5Gcreate_vers
only controls the mapping of the API compatibility macro
H5GCreate
to one of the two available functions.
This allows users to write code that can be used with any version of the
library since 1.6.8 and any library compilation options except
H5_NO_DEPRECATED_SYMBOLS
, by always using the "1" version of
versioned functions and types. For example, H5Gcreate1
will
always be interpreted in exactly the same manner by any version of the library
since 1.6.8.
This can be especially useful in any case where the programmer does not have direct control over global macro definitions, such as when writing code meant to be copied to multiple applications or when writing code in a header file.
configure
flag.
In this default mode, both 1.6.x and 1.8.x versions of the underlying functions are available,
and the API compatibility macros will be mapped to the 1.8.x version-numbered functions.
For example, H5Gcreate
will be mapped to H5Gcreate2
.
-DH5_USE_16_API
application mapping option,
and link with the HDF5 library built in step 1.
No changes should be required to build the application.
The API compatibility macros, for example H5Gcreate
, replace the
actual function names that were used in versions of the library prior to 1.8.0.
Because the application mapping overrides the library mapping,
the macros will all be mapped to the 1.6.x versions of the functions.
-DH5Gcreate_vers=2
version flag setting
to remap the H5Gcreate
macro to H5Gcreate2
, the 1.8.x version.
During this step, the application code will need to be modified to change the calling parameters
used with the API compatibility macros to match the number and type of the 1.8.x version-numbered
functions. The macro name, for example H5Gcreate
, should continue to be used in the code,
to allow for possible re-mappings to later version-numbered functions in a future release.
-DH5_NO_DEPRECATED_SYMBOLS
,
and address any failures to complete the application migration process.
The HDF Group Help Desk:
Describes HDF5 Release 1.8.18, November 2016. | Copyright by The HDF Group |