Microsoft社による独自拡張言語 C++/CLI*1 と C++/CX*2 の差分について。主に言語機能の観点での差分リスト。
MSDNフォーラムでのDeon Brewis氏*3回答による。引用中の/clrは C++/CLI に、/ZWは C++/CX に対応する(いずれもVisual C++のコンパイラオプション)。
Basic types:
/clr: From mscorlib.dll (System::* types)
/ZW: From vccorlib.dll (Platform::* types)Lifetime management:
/clr: Garbage collected
/ZW: RefcountedCycles Broken:
/clr: By garbage collector
/ZW: Broken by user (weak references or explicit delete)Code generation:
/clr: MSIL + native code. Can create a cross-platform binary if MSIL-only.
/ZW: Native code only. Binaries target a specific platform.Object Creation:
/clr: gcnew
/ZW: ref newinterior_ptr:
/clr: Supported
/ZW: Not supportedpin_ptr:
/clr: Supported
/ZW: Not supportedV% (% when it refers to a byref (kind'a like an "interior_ref") ):
/clr: Supported
/ZW: Not supportedR% (% when it refers to an implicitly dereferenced ref type):
/clr: Supported
/ZW: SupportedRef to ^:
/clr: R^%
/ZW: R^&Boxing:
/clr: syntax V^
/ZW: IReference^ Dereferenced box type:
/clr: V%
/ZW: const VGenerics:
/clr: Generics classes, interfaces & delegates allowed.
/ZW: Generic interfaces & delegates only.Static constructors:
/clr: Supported
/ZW: Not supportedAddress of member of ref class:
/clr: Returns an interior_ptr
/ZW: Returns a type*friends:
/clr: Not supported
/ZW: SupportedC++ class embedded in ref class:
/clr: Not supported
/ZW: Supportedref class embedded in C++ class:
/clr: Not supported
/ZW: Supported (R-on-stack)^ embedded in C++ class:
/clr: Not supported (Needs GCHandle)
/ZW: Supported^ embedded in value class with value class on native heap:
/clr: Not supported
/ZW: Supported (for String^)Global ^:
/clr: Not supported
/ZW: SupportedGlobal R-on-stack:
/clr: Not supported
/ZW: SupportedFinalizer:
/clr: Supported
/ZW: Not supportedDestructor:
/ZW: Runs on IDisposable::Dispose (delete / stack unwind) only
/clr: Runs on IDisposable::Dispose (delete / stack unwind) -or- last release (never both)T::typeid:
MSDN Forum, Differences between C++/CLI and WinRT C++
/clr: Supported
/ZW: Not supported
関連URL