W
Walter H.
Hi,
the following code snippet ...
const int nEnvLnCnt = 11;
System::String* strEnvVars[ ] = { S"ComSpec", S"Path", S"Prompt",
S"HomeDrive", S"HomePath", S"LogonServer", S"SystemDrive",
S"SystemRoot", S"UserDomain", S"UserProfile", S"UserName" };
System::String* strEnvLines[ ] = new System::String* [ nEnvLnCnt ];
for ( int iter = 0; iter < nEnvLnCnt; iter++ )
strEnvLines[ iter ] = System::String::Format( S"{0}={1}",
strEnvVars[ iter ], System::Environment::GetEnvironmentVariable(
strEnvVars[ iter ] ) );
this compiles without any errors or warnings but
System::String* strEnvVars[ nEnvLnCnt ] = { /* the same as above */ };
doesn't compile, why?
file.cpp(370) : error C3616: '11': a size cannot be specified in a __gc
array declaration
file.cpp(370) : error C3184: 'System::String __gc *strEnvVars
__gc[,,,,,,,,,,]' : initialization of multi-dimensional arrays via an
initializer list is not supported
file.cpp(370) : error C2440: '=' : cannot convert from 'System::String
__gc * __gc[]' to 'System::String __gc * __gc[,,,,,,,,,,]'
Cannot convert between __gc arrays of different ranks
file.cpp(370) : error C3262: invalid array indexing: 1 dimension(s)
specified for 11-dimensional 'System::String __gc * __gc[,,,,,,,,,,]'
....
the following code snippet ...
const int nEnvLnCnt = 11;
System::String* strEnvVars[ ] = { S"ComSpec", S"Path", S"Prompt",
S"HomeDrive", S"HomePath", S"LogonServer", S"SystemDrive",
S"SystemRoot", S"UserDomain", S"UserProfile", S"UserName" };
System::String* strEnvLines[ ] = new System::String* [ nEnvLnCnt ];
for ( int iter = 0; iter < nEnvLnCnt; iter++ )
strEnvLines[ iter ] = System::String::Format( S"{0}={1}",
strEnvVars[ iter ], System::Environment::GetEnvironmentVariable(
strEnvVars[ iter ] ) );
this compiles without any errors or warnings but
System::String* strEnvVars[ nEnvLnCnt ] = { /* the same as above */ };
doesn't compile, why?
file.cpp(370) : error C3616: '11': a size cannot be specified in a __gc
array declaration
file.cpp(370) : error C3184: 'System::String __gc *strEnvVars
__gc[,,,,,,,,,,]' : initialization of multi-dimensional arrays via an
initializer list is not supported
file.cpp(370) : error C2440: '=' : cannot convert from 'System::String
__gc * __gc[]' to 'System::String __gc * __gc[,,,,,,,,,,]'
Cannot convert between __gc arrays of different ranks
file.cpp(370) : error C3262: invalid array indexing: 1 dimension(s)
specified for 11-dimensional 'System::String __gc * __gc[,,,,,,,,,,]'
....