开发者

C++ CLI gcnew undeclared identifier

开发者 https://www.devze.com 2023-03-24 06:40 出处:网络
String* response_Page=\"\"; std::string http_Response; //WinHttp Request //http_Response append (pszOutBuffer);
String* response_Page="";
std::string http_Response;

//WinHttp Request
//http_Response append (pszOutBuffer);

response_Page = gcnew System::String(respstring);

I am trying to create a managed C++/CLI dll to be used in c#, new to C++, it is really complex, cant get much info just by searching.

Update: I am using Common Language Runtime Support, Old Sy开发者_C百科ntax (/clr:oldSyntax)

Getting error: error C2065: 'gcnew' : undeclared identifier


The error is caused by using new style managed C++ syntax with the /clr:oldSyntax compiler option. Either use old style syntax or use new style syntax and don't use the oldSyntax flag.

The only reason to use the oldSyntax flag is if you're maintaining legacy code. Other than that one reason, avoid the old syntax, it was yucky.


You need to use ^ instead of * to use gcnew. If you need an unmanaged pointer then use * with new

String^ response_Page="";

Also, there are lots of C++/CLI books out there; you should consider getting one. eBook format available. http://manning.com/ and http://www.apress.com/

  • C++/CLI in Action (Manning)
  • C++/CLI The Visual C++ Language for .NET (Apress)
  • Pro Visual C++/CLI and the .NET 2.0 Platform (Apress)
  • Expert Visual C++/CLI: .NET for Visual C++ Programmers (Apress)
  • Foundations of C++/CLI: The Visual C++ Language for .NET 3.5 (Apress)
  • Pro Visual C++/CLI and the .NET 3.5 Platform (Apress)
0

精彩评论

暂无评论...
验证码 换一张
取 消