When I have this c++ cli code:
#pragma managed
ref class mcSessions: ConcurrentDictionary <String ^, mcSession^>
{ //<---- warning here
private:
static mcSessions ^g_Sessions;
TimeSpan MaxIdleTime;
mcSessions (TimeSpan newMaxIdleTime);
public:
static void Initialize (long MaxIdleMinutes);
static void Shutdown ();
static void CreateSession (String ^&SessionId);
static void RunInSession (String ^SessionId, String ^Command);
static void RemoveSession (String ^SessionId);
};
I get a warning C4538 on the first {. Does anybody has any clue why this happens and what it warns for, or is this also a compiler bug as it is for the situation in this question: Seemingly inappropriate compilation warning with C++/CLI
Although I see they are somewhat related, I do not have a Group object but a ConcurrentDictionary. I am using Visual Studio 2010 targeting the .NET 4.0 framework and compiling with the /clr compiler flag on.
The exact error message is:
1>d:\t4edevnet2010\umra2\iampowershell\mcIpSessions.h(25): warning C4538: 'cli::array<Type,dimension> ^' : const/volatile qualifiers on this type are not supported
1> with
1> [
1> Type=System::Collections::Concurrent::ConcurrentDictionary::Node ^,
1> dimension=1
1> ]
1> This diagnostic occurred while importing type 'System::Collections::Concurrent::ConcurrentDictionary ' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
1>d:\t4edevnet2010\umra2\iampowershell\mcIpSessions.h(25): warning C4538: 'cli::array<Type,dimension> ^' : const/volatile qualifiers on this type are not supported
1> with
1> [
1> Type=int,
1> dimension=1
1> ]
1> This diagnostic occurred while importing type 'System::Collections::Concurrent::ConcurrentDictionary ' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
1>d:\t4edevnet2010\umra2\iampowershell\mcIpSessions.h(25): warning C4538: 'cli::array<Type,dimension> ^' : const/volatile qualifiers on this type are not supported
1> with
1> [
1> Type=System::Collections::Concurrent::ConcurrentDictionary<TKey,TValue>::Node ^,
1> dimension=1
1> ]
1> d:\t4edevnet2010\umra2\iampowershell\mcIpSessions.h(25) : see reference to class generic instantiation 'System::Collections::Concurrent::ConcurrentDictionary<TKey,TValue>' being compiled
1> d:\t4edevnet2010\umra2\iampowershell\mcIpSessions.h(25) : see reference to class generic instantiation 'System::Collections::Concurrent::ConcurrentDictionary<TKey,TValue>' being compiled
1> with
1> [
1> TKey=System::String ^,
1> TValue=IamPowershell::mcSession ^
1> ]
1> This diagnostic occurred while importing type 'System::Collections::Concurrent::ConcurrentDictionary::Node ' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
1>d:\t4edevnet2010\umra2\iampowershell\mcIpSessions.h(25): warning C4538: 'cli::array<Type,dimension> ^' : const/volatile qualifiers on this type are not supported
1> with
1> [
1> Type=int,
1> dimension=1
1> ]
1> This diagnostic occurred while importing type 'System::Collections::Concurrent::ConcurrentDictionary::Node ' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
1>d:\t4edevnet2010\umra2\iampowershell\mcIpSessions.h(25): warning C4538: 'cli::array<Type,dimension> ^' : const/volatile qualifiers on this type are not supported
1> with
1> [
1> Type=System::Collections::Concurrent::ConcurrentDictionary<System::String ^,mcSession ^>::Node ^,
1> dimension=1
1> ]
1>d:\t4edevnet2010\umra2\iampowershell\mcIpSessions.h(25): warning C4538: 'cli::array<Type,dimension> ^' : const/volatile qualifiers on this type are not supported
1> with
1> [
1> Type=int,
1> dimension=1
1> ]
1>
As @HansPassant noted in the comment on the question he is right. The members are indeed volatile (stupid me, could have checked that :S) Anyway that should be the answer.
Thankx I consider it solved now.