2

我正在玩一个与我的 Isis2 (C# .NET) 库对话的 C++/CLI 应用程序。在下面的代码中,我收到错误“警告 3 C4538:'cli::array ^':不支持此类型的 const/volatile 限定符”。我突出显示了引发此问题的行。我很困惑:这没有数组,也没有使用 const 或 volatile!有什么建议么?

// CPlusPlus.cpp : main project file.

#include "stdafx.h"
#using <IsisLib.dll>
using namespace Isis;
using namespace System;

void GotNewView(View^ v)
{
   Console::WriteLine("Got a new view: " + v->ToString());
}

public delegate void GotAnInt_T (int i);
void GotAnInt(int i)
{
   Console::WriteLine("Got an int: {0}", i);
}

public delegate void GotTwo_T (String ^s, double d);
void GotTwo(String^ s, double d)
{
   Console::WriteLine("Got a string: <{0}> and a double: {1}", s, d);
}

public delegate void SendsReply_T(int i);
void SendsReply(int i)
{
   thisGroup()->Reply(-i);
}

int main(array<System::String ^> ^args)
{ 
   IsisSystem::Start();
   Group ^g = gcnew Group("test");       <============= THIS LINE
   g->RegisterViewHandler(gcnew ViewHandler(GotNewView));
   g->Handlers[0] += gcnew GotAnInt_T(GotAnInt);
   g->Handlers[0] += gcnew GotTwo_T(GotTwo);
   g->Handlers[1] += gcnew SendsReply_T(SendsReply);
   g->Join();
   g->Send((int^)0, 12345);
   g->Send((int^)0, "Aardvarks are animals", 78.91);
   Console::WriteLine("After Send, testing Query");
   Collections::Generic::List<int>^ results = gcnew Collections::Generic::List<int>();
   int nr = g->Query(Group::ALL, 1, 6543, gcnew EOLMarker(), results);
   IsisSystem::WaitForever();
   return 0;
}
4

1 回答 1

1

这是一个已知的编译器错误:它警告Group. 它不应该那样做。

推荐的解决方法是禁用警告:

#pragma warning (disable: 4538)

可能只对有问题的代码行禁用警告,尽管我不是 100% 确定,因为 C++/CLI 代码中没有任何东西会导致这个问题。你可以试试:

#pragma warning (push)
#pragma warning (disable: 4538)
Group^ g = gcnew Group("test");
#pragma warning (pop)
于 2012-08-28T00:08:03.277 回答