Commit e945ae8c authored by Kai Germaschewski's avatar Kai Germaschewski
Browse files

fix HDF5Reader build with MSVC

Sadly, variable-sized stack arrays are only a feature of C99, but not C++11,
so this patch uses std::vector instead.
parent 58b8e989
......@@ -14,6 +14,8 @@
#include "adios2/common/ADIOSMPI.h"
#include "adios2/helper/adiosFunctions.h" //CSVToVector
#include <vector>
namespace adios2
{
namespace core
......@@ -146,7 +148,7 @@ size_t HDF5ReaderP::ReadDataset(hid_t dataSetId, hid_t h5Type,
}
else
{
hsize_t start[ndims], count[ndims], stride[ndims];
std::vector<hsize_t> start(ndims), count(ndims), stride(ndims);
bool isOrderC = helper::IsRowMajor(m_IO.m_HostLanguage);
for (int i = 0; i < ndims; i++)
......@@ -164,12 +166,12 @@ size_t HDF5ReaderP::ReadDataset(hid_t dataSetId, hid_t h5Type,
slabsize *= count[i];
stride[i] = 1;
}
hid_t ret = H5Sselect_hyperslab(fileSpace, H5S_SELECT_SET, start,
stride, count, NULL);
hid_t ret = H5Sselect_hyperslab(fileSpace, H5S_SELECT_SET, start.data(),
stride.data(), count.data(), NULL);
if (ret < 0)
return 0;
hid_t memDataSpace = H5Screate_simple(ndims, count, NULL);
hid_t memDataSpace = H5Screate_simple(ndims, count.data(), NULL);
interop::HDF5TypeGuard g_mds(memDataSpace, interop::E_H5_SPACE);
int elementsRead = 1;
......
......@@ -15,6 +15,7 @@
#include <ios>
#include <iostream>
#include <stdexcept>
#include <vector>
#include "adios2/common/ADIOSMPI.h"
#include "adios2/helper/adiosFunctions.h" // IsRowMajor
......@@ -419,8 +420,8 @@ void HDF5Common::AddVar(core::IO &io, std::string const &name, hid_t datasetId,
{
hid_t dspace = H5Dget_space(datasetId);
const int ndims = H5Sget_simple_extent_ndims(dspace);
hsize_t dims[ndims];
H5Sget_simple_extent_dims(dspace, dims, NULL);
std::vector<hsize_t> dims(ndims);
H5Sget_simple_extent_dims(dspace, dims.data(), NULL);
H5Sclose(dspace);
Dims shape;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment