2

I'm writing a program that makes heavy use of C++ 20 and newer features. The problem is that in the project I need the stxxl library, which is compiled exclusively on C++ 14 . If I try to include it as described in this guide (via .h files and .lib), Visual Studio throws a lot of errors related to the fact that some old features and language constructs no longer work in new versions.

Is it possible to somehow use this library in the project?

Chase
  • 43
  • 4
  • Normally I'd hide it from sight behind an abstraction layer compiled with C++14, but I can't think of a decent way to do this with templates. – user4581301 Sep 16 '22 at 22:24
  • Strange way to ask for help, but different strokes I guess. – Taekahn Sep 17 '22 at 00:31
  • 1
    @PeteBecker there are lots of deprecated things in C++17/20/23 so the warnings are unsurprising at all. The only way in this case is to build the library separately then link – phuclv Sep 17 '22 at 01:09
  • @phuclv I build this library separately using C++ 14, but how to link it to the current project? I would be very grateful for a hint – Chase Sep 17 '22 at 01:18
  • @phuclv — deprecated means they **might** be removed in the future. Until then they are still valid. That’s exactly the kind of thing I was talking about; if the compiler refuses to compile something because it’s deprecated it’s being used in a non-conforming mode. – Pete Becker Sep 17 '22 at 01:42
  • @PeteBecker depecated means a warning must be emitted. That's why C++ even has the `[[deprecated]]` attribute to force a warning on things that should not be used – phuclv Sep 17 '22 at 02:13
  • 1
    @phuclv — last I knew, the C++ standard did not even mention warnings. The only requirement was that a conforming compiler had to issue a diagnostic when it was asked to compile a non-conforming program. If there now are mandatory warnings, can you point me to the words that impose that requirement? Note that [cppreference](https://en.cppreference.com/w/cpp/language/attributes/deprecated), while not authoritative, says only that “Compilers typically issue warnings on such uses.” And even if the compiler produces a warning, it is not allowed to refuse to compile deprecated constructs. – Pete Becker Sep 17 '22 at 02:30
  • @phuclv you should google his name. Probably the wrong person to debate the c++ standard with. Assuming he is actually _the_ Pete Becker. – Taekahn Sep 17 '22 at 02:54
  • 2
    @PeteBecker one example: std::bind2nd, function used in stxxl, which I need, deprecated in C++ 14 and... removed in C++ 17. Never will be? – Chase Sep 17 '22 at 03:43
  • 1
    You could write a library that does not expose any of the stxxl types and functions directly but only wrappers of them. Of course, you loose all the template magic in the API and instead you have to hardcode each type. E.g. of `vector` you'd only expose `VectorIntWrapper`. The library can then be compiled in C++14. Actually, to avoid any problems with ABIs, I'd write a C-style wrapper that does not expose C++ types. See e.g. [here](https://stackoverflow.com/questions/17912107/how-to-wrap-a-c-class-in-a-c-based-dll-or-a-cli-based-dll). – Sedenion Sep 17 '22 at 06:47
  • @Sedenion thank you very much, i`ll read everything about it – Chase Sep 17 '22 at 08:19
  • @Sedenion Maybe you are aware of another library or solution that can replace stxxl? There is too much trouble, and another problem arises that I can’t just transfer the exe file to users, I will have to use it exclusively together with stxxl.dll, and this is inconvenient – Chase Sep 18 '22 at 00:40
  • Sorry, before your post I had never even heard of stxxl. Maybe you could instead make stxxl C++20 compatible yourself? Or possibly try the pull requests mentioned [here](https://github.com/stxxl/stxxl/issues/90)? – Sedenion Sep 18 '22 at 07:12
  • @Sedenion ty, but I tried this and pr`s wont help: I still need C++20, but it doesn't compile. I don’t know, there are a lot of strange errors in huge files with tens of thousands of lines of code, and it’s not possible to figure out and fix the library on my own, as it seems to me ( – Chase Sep 19 '22 at 19:01

0 Answers0