Last Modified: June 1, 2002
The following options are incompatible with the /clr compiler
switch:
If type 'X' is a reference object, you won't be able to consume any of the
overloaded managed operators it might have defined. This is because there's a
real impedance mismatch between operator overloading and the fact that in MC++
reference objects have to be accessed through pointers. Since standard C++,
from which MC++ sort of came out, explicitly defines semantics for standard
operators on pointers, such as the meaning of order relations (<, >, =, etc.),
the use of actual operators would conflict with them.
Note that you should be able to use some overloaded operators on value types,
though.
Yes, using the appropriate operator name (such as op_Addition
.
However, not all managed operators defined by the CLR can be overloaded on the
first release of MC++, because of compiler bugs. Look
here for detailed information on those.
If you want to define a method that takes a reference argument (that is, and
in/out argument) that C# programs can see defined as "ref", you can use the C++
reference (&) syntax.
However, if the type of the argument is one of the basic types, and you try to
use the C++ name for the type, this won't compile at first. For example, this
won't work:
void MethodWithRef(int& v);
The simplest workaround is to use the CLR's typename, instead:
void MethodWithRef(System::Int32& v);
Try something like this:
void MethodWithRef(System::Int32 (&intArray) __gc[]) {
const size_t arraySize = 2;
intArray = new int __gc[arraySize];
// fill array
}
You're probably doing something like this:
public __gc class MyCustomAttribute : public Attribute
{
public:
MyCustomAttribute(String* desc) {
}
// rest of implementation
};
__value enum MyEnum {
[ MyCustomAttribute(S"Value 1") ]
value_1 = 1,
[ MyCustomAttribute(S"Value 2") ]
value_2 = 2,
};
And you're getting a C2143 and a few other errors, right? The cause is a bug in
the current MC++ compiler that doesn't allow it to parse attributes in an enum
declaration, so there's no workaround for it.