【问题标题】:Problems with stdstring and hdf5stdstring 和 hdf5 的问题
【发布时间】:2016-01-12 09:35:41
【问题描述】:

我正在使用 Microsoft Visual Studio 2008 (HDF5 v1.8.12),但每个函数都使用 H5std_string 作为参数存在问题。


当我运行示例文件“create.cpp”时也是如此 https://www.hdfgroup.org/ftp/HDF5/current/src/unpacked/c++/examples/create.cpp

这给了我错误: ....\H5F.c H5Fcreate() 中的第 1466 行:文件名无效 当我将 FILE_NAME 替换为 FILE_NAME.c_str() 时,该错误已修复 和DATASET_NAMEDATASET_NAME.c_str()


运行时同样报错:

H5::Attribute attr = group.openAttribute("type");
H5std_string attr_content;
attr.read(attr.getStrType(), attr_content);

但是下面的代码可以工作

char buf[1024];
H5::Attribute attr = group.openAttribute("type");
attr.read(attr_date.getStrType(), buf);

【问题讨论】:

  • 我认为你应该打电话给getDataType()而不是getStrType()
  • 使用 getDataType() 没有帮助。该问题纯粹与使用标准字符串有关。使用char* 的函数可以正常工作,但是每当我使用以H5std_string 作为参数的相应函数时都会出错。
  • 看起来类似于这个答案:stackoverflow.com/questions/32072272/…

标签: c++ visual-c++ hdf5 stdstring


【解决方案1】:

在 Visual Studio 中切换到发布模式时,下面显示的错误消失了。

Using std:: string in hdf5 creates unreadable output

【讨论】:

    猜你喜欢
    • 2010-12-16
    • 2019-05-26
    • 1970-01-01
    • 2017-03-14
    • 2017-04-05
    • 2016-10-24
    • 2020-11-30
    • 2013-06-09
    • 2012-12-11
    相关资源
    最近更新 更多