首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >C++/CLI的似乎不正确的编译警告

C++/CLI的似乎不正确的编译警告
EN

Stack Overflow用户
提问于 2012-08-28 07:47:43
回答 1查看 1.5K关注 0票数 2

我正在玩一个与我的Isis2 (C# .NET)库对话的C++/CLI应用程序。在下面的代码中,我得到了错误"Warning 3 C4538:‘cli::ARRAY^’:不支持此类型的常量/易失性限定符“。我突出显示了抛出此问题的代码行。我很困惑:它既没有数组,也没有使用const或volatile!有什么建议吗?

代码语言:javascript
复制
// 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;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-28 08:08:03

这是一个已知的编译器错误:它对Group的易失性数组成员发出警告。它不应该这样做。

建议的解决方法是禁用警告:

代码语言:javascript
复制
#pragma warning (disable: 4538)

可以仅针对有问题的代码行禁用该警告,尽管我不能100%确定,因为C++/CLI代码中没有导致此问题的任何内容。您可以尝试:

代码语言:javascript
复制
#pragma warning (push)
#pragma warning (disable: 4538)
Group^ g = gcnew Group("test");
#pragma warning (pop)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12151060

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档