My original question was if MC++ supports C#'s out/ref semantics, which I
also meant if MC++ compiler _enforces_ the restrictions to out/ref as C#
compiler does -- that part I think I was not clear enough up-front. For
example, the following C# code gives compilation errors, which is as
expected:
class MyApp
{
static void F1(out int i) {} // Error CS0177
static void F2(ref int i) {}
public static void Main()
{
int i, j;
F1(out i);
F2(ref j); // Error CS0165
}
}
Error CS0177: The out parameter 'i' must be assigned to before control
leaves the current method
Error CS0165: Use of unassigned local variable 'j'
But the following MC++ code compiles without any error:
#using <mscorlib.dll>
void F1([System::Runtime::InteropServices::OutAttribute] int* pi) {}
void F2(int* pi) {}
int main()
{
int i, j;
F1(&i);
F2(&j);
}
So, supposedly MC++ has no facility that is semantically equivelant to C#'s
out/ref?
Simon
"Jochen Kalmbach" <no********************@holzma.de> wrote in message
news:Xn**********************************@207.46.2 48.16...
Simon Cheng wrote:
They don't enforce C#'s out/ref semantics. For example, the following
MC++ code compiles fine:
void F1([System::Runtime::InteropServices::OutAttribute] Int32*
pi) {}
Hä !?
This is wrong... it will compile but it is wrong..
you have to return an value, for example "*pi = 12"...
void F2(Int32* pi) {}
This is ok.
But the equivalent C# code would fail compilation because:
- F1() doesn't write to *pi before returning.
- j is not written before passed to F2().
Hä !?
Please provide a full example...
--
Greetings
Jochen
Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp
Do you need daily reports from your server?
http://sourceforge.net/projects/srvreport/