Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot include msclr\marshal_cppstd.h - _This_conversion_is_not_supported

I have a CLI project, that is using marshal to convert String^ to std::string. For some reason when I include the header, I get these compile errors that I don't seem to understand.

Even when I don't make any calls to marshal_as, I still get the compile errors.

I've looked online to no help.

Maybe you can help?

Code:

#include <msclr\marshal_cppstd.h>


namespace ConnectionWrapper
{
  inline std::string ToStdString(System::String^ str)
  {
    return msclr::interop::marshal_as<std::string>(str);
  }

  inline System::String^ ToCliString(const std::string std)
  {
    return msclr::interop::marshal_as<System::String^>(std);
  }
}

Compile Errors:

1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.15.26726\include\msclr\marshal.h(222): error C3861: '_This_conversion_is_not_supported': identifier not found
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.15.26726\include\msclr\marshal.h(224): note: see reference to class template instantiation 'msclr::interop::error_reporting_helper<_To_Type,_From_Type,false>' being compiled
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.15.26726\include\msclr\marshal.h(233): error C3861: '_This_conversion_requires_a_context': identifier not found
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.15.26726\include\msclr\marshal.h(235): note: see reference to class template instantiation 'msclr::interop::error_reporting_helper<_To_Type,_From_Type,true>' being compiled
like image 745
Ilan Keshet Avatar asked May 07 '26 03:05

Ilan Keshet


1 Answers

I solved the problem.. though I don't really understand how. -- I turned off the /permissive flag -- and everything built fine

like image 151
Ilan Keshet Avatar answered May 09 '26 17:05

Ilan Keshet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!