surge-synthesizer / conduit

The Surge Synth Team Conduit Plugin Suite
Other
14 stars 4 forks source link

Errors trying to build with C++20 #90

Closed elanhickler closed 9 months ago

elanhickler commented 10 months ago

When I try to switch conduit to build with C++20, I get errors.

Severity Code Description Project File Line Suppression State Error C2679 binary '<<': no operator found which takes a right-hand operand of type 'std::basic_string<char8_t,std::char_traits,std::allocator>' (or there is no acceptable conversion) conduit-impl F:(PROGRAMMING)\clapconduithydrus\src\conduit-shared\clap-base-class.h 604

if (operation == SAVE)
              {
                  std::ofstream ofs(fsp, std::ios::out | std::ios::binary);
                  if (!ofs.is_open())
                  {
                      CNDOUT << "Unable to open for writing " << fsp.u8string() << std::endl;
                      return;
                  }
                  CNDOUT << "Writing patch to " << fsp.u8string() << std::endl;
                  clap_ostream cos{};
                  cos.ctx = &ofs;
                  cos.write = clapwrite;
                  that.stateSave(&cos);
                  ofs.close();
              }

Severity Code Description Project File Line Suppression State Error C2440 'return': cannot convert from 'std::basic_string<char8_t,std::char_traits,std::allocator>' to 'std::basic_string<char,std::char_traits,std::allocator>' conduit-impl F:(PROGRAMMING)\clapconduithydrus\build\libs\sst\sst-plugininfra\libs\filesystem\include\filesystem\import.h 21

inline std::string path_to_string(const fs::path& path)
{
#ifdef _WIN32
   return path.u8string();
#else
   return path.generic_string();
#endif
}

Severity Code Description Project File Line Suppression State Error C2088 '<<': illegal for class conduit-impl F:(PROGRAMMING)\clapconduithydrus\src\conduit-shared\clap-base-class.h 607

if (!ifs.is_open())
{
    CNDOUT << "Unable to open for reading " << fsp.u8string() << std::endl;
    return;
}
baconpaul commented 10 months ago

To build with C++20 you need the utf8 string fix.

$<$<COMPILE_LANGUAGE:CXX>:-fno-char8_t>

add that to the compile options or better add it if the version >= 20

baconpaul commented 10 months ago

https://github.com/surge-synthesizer/surge/blob/4b53827e05959ab33a1787bd81cfacf190c843d3/CMakeLists.txt#L92C5-L92C44

baconpaul commented 10 months ago

(the c++20 insistence that a utf8 char and a char are not the same is a huge clusterf**k by the way, which is mostly fixed in 23; that flag turns it off)

elanhickler commented 9 months ago
  add_compile_options(
    # Do *not* use the new, breaking char8_t UTF-8 bits in C++20.
    $<$<COMPILE_LANGUAGE:CXX>:-fno-char8_t>
  )

which cmake file do you add this to? i tried the one in src and the one in the main folder already, still getting char errors

I also changed the line set(CMAKE_CXX_STANDARD 20) so it would be 20 instead of 17

baconpaul commented 9 months ago

I just pushed them in in b1cc695

if you pull that then set standard to 20 it will build all platforms.