小编Ken*_*ock的帖子

如何使用 h5py 编写空终止固定长度字符串的数据集

我有一个 C++ 示例,我试图使用 h5py 重现它,但它没有按预期工作。我用 h5py 得到了空填充字符串,我期望空终止字符串。

这是我的 C++ 驱动程序...

main.cpp

#include <hdf5.h>

int main(void) {
    auto file = H5Fcreate("test-c.h5", H5F_ACC_TRUNC,
            H5P_DEFAULT, H5P_DEFAULT);
    char strings[5][64] = {
        "please work 0",
        "please work 1",
        "please work 2",
        "please work 3",
        "please work 4"};
    auto H5T_C_S1_64 = H5Tcopy (H5T_C_S1);
    H5Tset_size(H5T_C_S1_64, 64);
    hsize_t dims[1] = {5};
    auto dataspace = H5Screate_simple(1, dims, NULL);
    auto dataset = H5Dcreate(file, "test dataset", H5T_C_S1_64, dataspace,
            H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
    H5Dwrite (dataset, H5T_C_S1_64, H5S_ALL, H5S_ALL, H5P_DEFAULT, strings);
    H5Dclose(dataset);
    H5Sclose(dataspace);
    H5Tclose(H5T_C_S1_64); …
Run Code Online (Sandbox Code Playgroud)

python h5py

5
推荐指数
1
解决办法
1136
查看次数

为什么在dlopen'd函数内传递std :: any的std :: any_cast会引发错误

我正在玩c ++ 17和插件,我遇到了一个我无法解决的错误.在下面的MWE中,我可以调用一个带有a的本地函数,std::any当我尝试读取内容时,一切都按预期工作.当我通过插件(dlopen)加载这个完全相同的函数时,它正确地看到了any上的类型,但它不能std::any_cast是内容.

在弄清楚导致此错误的原因时,将非常感谢任何帮助.

这是我的环境,MWE和产生的错误.

>> g++ --version

g++ (GCC) 7.1.1 20170526 (Red Hat 7.1.1-2)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Run Code Online (Sandbox Code Playgroud)

>> scons --version

SCons by Steven Knight et al.:
    script: v2.5.1.rel_2.5.1:3735:9dc6cee5c168[MODIFIED], 2016/11/03 14:02:02, by bdbaddog on mongodog
    engine: v2.5.1.rel_2.5.1:3735:9dc6cee5c168[MODIFIED], 2016/11/03 14:02:02, by bdbaddog on mongodog
    engine path: ['/usr/lib/scons/SCons']
Copyright (c) …
Run Code Online (Sandbox Code Playgroud)

c++ scons dlopen c++17 stdany

3
推荐指数
1
解决办法
481
查看次数

标签 统计

c++ ×1

c++17 ×1

dlopen ×1

h5py ×1

python ×1

scons ×1

stdany ×1