Reputation: 276
Or are you restricted to the "Metro-style" applications and Windows Store apps?
At first, I thought C++/CX would be a good alternative to C++/CLI as it has some nifty C#-esque keywords ('sealed', 'partial') and it also compiles to native code, rather than using .NET. But reading online, all I can find is information regarding Windows Store apps and Metro-styled applications...
Also, is WinRT for Windows 8 and above only?
Upvotes: 6
Views: 3542
Reputation: 265
the first line on the wikipedia page for C++/CX is
C++/CX (component extensions) is a language extension for C++ compilers from Microsoft that enables C++ programmers to write programs for the new Windows Runtime platform, or WinRT. (emphasis added)
So it appears that C++/CX is to WinRT as C++/CLI is to .Net/CLR. I.e C++/CX is for writing windows Apps with WinRT. WinRT is for windows 8 store and metro apps.
You can write regular windows API apps in C++, so you might be able to do the same in C++/CX. But it may not be easy or possible, but since the extensions are specific to WinRT, why would you want to. C++/CLI compiles to CLR bytecode, to be run with the common language runtime. Getting C++/CX to generate an executable that doesn't depend on WinRT, is the crux of the issue.
This SO post indicates that yes WinRT is only for Windows 8. (Presumably Windows 10 as well.)
Upvotes: -3
Reputation: 21889
Yes, you can write desktop apps in C++/Cx and can use some Windows Runtime API (those marked in the documentation and headers as available for desktop apps) in desktop apps. See Windows Runtime APIs for desktop apps. The Enumerate app packages sample on MSDN demonstrates using C++/Cx to call Windows Runtime API in a desktop app.
The Windows Runtime Xaml classes are not available to desktop apps, but since you can mix-and-match C++ and C++/Cx you can call typical desktop UI API (Win32, MFC, DirectX, etc.) from an app which also uses C++/Cx.
C++/Cx isn't really an alternative to C++/CLI. Other than using some similar syntax they have quite different goals. As you note, C++/Cx is not a managed language and so it cannot be used to call managed code. The primary reason to choose C++/CLI is for interop with managed code. C++/Cx is a good option if you need to call into the Windows Runtime from your desktop app.
The Windows Runtime is available only on Windows 8 and later.
Upvotes: 12