Не могу включить msclr \ marshal_cppstd.h - _This_conversion_is_not_supported - PullRequest
0 голосов
/ 21 сентября 2018

У меня есть проект CLI, который использует маршал для преобразования String ^ в std :: string.По какой-то причине, когда я включаю заголовок, я получаю эти ошибки компиляции, которые, кажется, не понимаю.

Даже когда я не делаю никаких вызовов marshal_as, я все равно получаю ошибки компиляции.

Я посмотрел в Интернете, чтобы помочь.

Может быть, вы можете помочь?

Код:

#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);
  }
}

Ошибки компиляции:

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

Ответы [ 2 ]

0 голосов
/ 23 октября 2018

Большое спасибо за это предложение, я только что столкнулся с той же проблемой.

Снятие флага /permissive решило ее.Кстати, я заметил, что этот флаг для C ++ CLR Empty Project для Windows выключен (/ SUBSYSTEM: WINDOWS), тогда как для консольного проекта Windows он включен (VS 2017 / .Net 4.7).

0 голосов
/ 22 сентября 2018

Я решил проблему .. хотя я не очень понимаю, как.- Я выключил флаг / permissive - и все нормально собралось

...