TRIQS / h5

A high-level C++ interface to the hdf5 library
https://triqs.github.io/h5
Other
3 stars 7 forks source link

add stl header for string conversion with gcc #1

Closed phdum closed 4 years ago

phdum commented 4 years ago

Hi,

I was trying to compile the code on the cluster machines using just gcc 9.4.0 and the gcc standard library. I got the error

/mnt/home/pdumitrescu/Documents/coding/repos/kryqup/build/deps/h5_src/c++/h5/stl/vector.cpp:65:32: error: cannot convert 'std::__cxx11::basic_string<char>::iterator' {aka '__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >'} to 'const char*'
   65 |       x.erase(std::remove(begin(x), end(x), '\0'), end(x));
      |                           ~~~~~^~~
      |                                |
      |                                std::__cxx11::basic_string<char>::iterator {aka __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >}
In file included from /cm/shared/sw/pkg/devel/gcc/9.3.0/include/c++/9.3.0/cstdio:42,
                 from /cm/shared/sw/pkg/devel/gcc/9.3.0/include/c++/9.3.0/ext/string_conversions.h:43,
                 from /cm/shared/sw/pkg/devel/gcc/9.3.0/include/c++/9.3.0/bits/basic_string.h:6493,
                 from /cm/shared/sw/pkg/devel/gcc/9.3.0/include/c++/9.3.0/string:55,
                 from /cm/shared/sw/pkg/devel/gcc/9.3.0/include/c++/9.3.0/bits/locale_classes.h:40,
                 from /cm/shared/sw/pkg/devel/gcc/9.3.0/include/c++/9.3.0/bits/ios_base.h:41,
                 from /cm/shared/sw/pkg/devel/gcc/9.3.0/include/c++/9.3.0/ios:42,
                 from /cm/shared/sw/pkg/devel/gcc/9.3.0/include/c++/9.3.0/istream:38,
                 from /cm/shared/sw/pkg/devel/gcc/9.3.0/include/c++/9.3.0/sstream:38,
                 from /cm/shared/sw/pkg/devel/gcc/9.3.0/include/c++/9.3.0/complex:45,
                 from /mnt/home/pdumitrescu/Documents/coding/repos/kryqup/build/deps/h5_src/c++/h5/stl/./vector.hpp:3,
                 from /mnt/home/pdumitrescu/Documents/coding/repos/kryqup/build/deps/h5_src/c++/h5/stl/vector.cpp:1:

I fixed this by adding the stl algorithm header, which solved this issue.

(In my experience gcc is less forgiving there than clang).

See also a similar issue in cpp2py.

Thanks!