Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use pure native C++ to write apps for windows 8 metro?

With native c++, I mean, not managed c++, not cli, not any special things from microsoft, I can:

1) get high performance 2) use existing c++ code library and engine 3) write cross platform code (for example, for ios and android)

it needn't be fully native c++, I can use managed code to do the ui things, like object-c in ios and java in android, but beside interface, can I use native c++ code?

like image 460
Ming Dong Avatar asked Oct 26 '12 15:10

Ming Dong


2 Answers

I suggest you have a look at the presentation here: Using the Windows Runtime from C++ and especially at the comments from Herb Sutter. I quote:

Please answer this question: If I decide to write C++ GUI application in Metro style am I forced to use all these proprietary ref, sealed, ^, Platform::String^ extensions for GUI components or not?

@Tomas: No, you are not forced to use them. We are providing two supported ways:

1) These language extensions (C++/CX).

2) A C++ template library (WRL), see Windows Kits\8.0\Include\winrt\wrl as Yannick mentioned. WRL is a C++ library-based solution sort of along the lines of ATL, which offers what I think you're looking for -- template wrapper/convenience classes and explicit smart pointers and such.

like image 90
Simon Mourier Avatar answered Nov 14 '22 23:11

Simon Mourier


Yes you absolutely can, real native C++ is fully supported.

You do however mostly have to use the new WinRT libraries to do an user interface or system calls and although they are native code and fully callable from C++ directly the interface to them makes it very painful indeed to do so, as everything is a reference counted COM object and in addition it's not so easy to create instances of them as just calling "new" so you have to write a lot of ugly code to do so.

As the earlier answer said, microsoft provide two ways to help with this. One is via language extensions to c++ and the other is a c++ template library. Personally I consider both to be rather ugly for doing something as simple as calling an API but that's just me :)

But to answer your question, it's completely possible to write your application in real native c++. You won't need to use managed code at all for anything. But you'll probably want to use either the language extensions or the template library to make calling the API more easy.

Personally I'm hoping someone writes a wrapper for WinRT that exposes the most necessary functionality as a more usable c++ native library and then everyone can just use that from c++ instead...

like image 36
jcoder Avatar answered Nov 15 '22 00:11

jcoder