Issue with H5 Exceptions (C4251 warning)


#1

Hi, folks, I’m having an issue with the H5Exception class that’s causing all sorts of other weird errors. I’m running the C++ code below in VS Community 2017 (it is the contents of a source file that gets exported to a DLL, which gets called by another app), with HDF 1.12.0. When I build the DLL, I get two warnings, both C4251:

  1. ‘H5::Exception::detail_message’: class ‘std::basic_string<char,std::char_traits,std::allocator>’ needs to have dll-interface to be used by clients of class ‘H5::Exception’
  2. ‘H5::Exception::func_name’: class ‘std::basic_string<char,std::char_traits,std::allocator>’ needs to have dll-interface to be used by clients of class ‘H5::Exception’

Then, when the console app is run and the function is called, the line that declares grX throws an error that, after a few calls, reads

Exception thrown: read access violation.
_Pnext was 0xFFFFFFFFFFFFFFFF. occurred.

I think there’s at least one other thread here having H5::Exception issues of this type, but it never got resolved, so I wanted to see if a new thread could yield any info.


#include “pch.h”
#include “H5Lib1.h”

#include
#include

#include “H5Cpp.h”
#include <H5Exception.h>

int getTagNum(char* filename) {
H5::H5File file(filename, H5F_ACC_RDONLY);
H5::Group tag_group(file.openGroup(“Tags”));

hsize_t numTagsSets = tag_group.getNumObjs();
std::cout << "There are " << numTagsSets << " objects in this group." << std::endl;
H5std_string grX = tag_group.getObjnameByIdx(1);

return 1;

}


#2

#pragma warning(disable : 4251)


#3

Thanks for the response, @gheber. I could disable the warnings, but I still get an error when I run the program, as stated in the text. I was providing the warnings more as a possible clue as to what the issue might be.


#4

I can try to look into the issue if it’s possible for me to have the file. Thanks!


#5

Thanks, @bmribler. Unfortunately it looks like I can’t upload files as I’m a new user still. Could I possibly email you or the HDF5 support staff? Thanks again for offering to look at it! It’s not crucial for my project, but I can’t imagine it’s anything either than (1) a bug with the HDF5 libraries or (2) an error on my part about using said libraries that I don’t understand.


#6

How big is your file?