I am not sure if this is related to my previous thread
("NullReference Exception with value struct") so I am starting a new
thread.
I saw in
http://msdn.microsoft.com/library/de...nagedtypes.asp
they mention that value types cannot contain pointers to other managed
types. In my __value struct, I had an array of other __value objects,
so I changed it to an unmanaged array. Now, when I compile using /Ox
for full optimization, I get an Internal Compiler Error.
Can anybody propose a workaround? Upgrading to VS 2005 is not an option
at the time.
// Test.h
#pragma once
#using <mscorlib.dll >
#using <System.dll>
#using <System.Windows .Forms.dll>
namespace ICE
{
public __gc class Test : public System::Windows ::Forms::Form
{
public:
Test(void) { }
static const int max_contours = 5;
__value struct Contours {
int num_contours;
__value struct ContourInfo {
double lower_bound;
int r;
int g;
int b;
} contours __nogc[max_contours];
//ContourInfo contours[];
//Contours()
// : contours(new ContourInfo[max_contours])
//{ }
};
protected:
void Dispose(System: :Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispos e(disposing);
}
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::Compone ntModel::Contai ner* components;
private:
bool is_blank(const Contours& contours)
{
Contours::Conto urInfo empty = {0, 0, 0, 0};
bool blank = true;
for (int i = 0; i < contours.num_co ntours; ++i) {
if (!__box(contour s.contours[i])->Equals(__box(e mpty))) {
blank = false;
}
}
return blank;
}
};
}
// Test.cpp
#include "Test.h"
#include <windows.h>
#using <mscorlib.dll >
int main()
{
ICE::Test* t = new ICE::Test;
}
Compile command:
cl /clr /Ox Test.cpp
Output:
Microsoft (R) C/C++ Optimizing Compiler Version 13.10.3077 for .NET Framework
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
Test.cpp
c:\documents and settings\kwokmb 1\my documents\work\ code\test.h(61) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'f:\vs70builds\ 3077\vc\Compile r\Utc\src\p2\wv m\mdmiscw.c', line 754)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
Note: The compiler file they list above does not exist on my system.
--
Marcus Kwok
Replace 'invalid' with 'net' to reply