| | > David is right, passing value types by ref must use %.
| > This is managed C++/CLI (managed code using /clr compileroption)
compiler
| > syntax not C++/ISO, & if for unmanaged code (or mixed) only.
|
| <snip>
|
| > will pass when compiled with /clr, but produces unverifiable code, it
| > won't
| > compile at all using clr
ure or /clr:safe.
|
|
| I see what you are saying... but I don't see the same thing with this
| program in VS.NET 2005,
|
| #include "stdafx.h"
| #include "stdio.h"
|
| using namespace System;
|
| static void Change(int& m) {
| m = 3;
| return;
| }
|
| int main(array<System::String ^> ^args) {
| int m = 1;
| Change(m);
| printf("%d\n", m);
| return 0;
| }
|
|
| These two project settings compile cleanly with no warnings...
| Common Language Runtime Support (/clr)
| Pure MSIL Common Language Runtime Support (/clr
ure)
|
| While this one gives 466 errors, probably int& is in their somewhere, but
so
| is everything + the kitchen sink.
| Safe MSIL Common Language Runtime Support (/clr:safe)
|
Yes, but while your code compiles to MSIL (option pure) without a warning,
it generates unverifiable code, that means it cannot be called from pure
managed language code like C# (even not using PInvoke), native pointers
(int&) are non verifiable, really.
Try running peverify on the produced assembly Compiled with /clr, you'll get
a Unverifiable PE header error..., compile it with 'pure' as option and
watch the error list scroll of the screen when running PEverify. That means
that these assemblies are standalone non callable from anything else than
C++/CLI.
My code compiles to mixed code (the one with the #pragma unmanaged) which is
unverifiable by nature (the PE header indicates this), but it's still
callable from C# (the managed portion only though.
Note also, a ref class member function cannot use int&, the correct syntax
is int%.
Willy.