Archive

Archive for May, 2012

Overview of Windows Runtime C++ Template Library

May 26th, 2012 No comments

The Windows Runtime C++ Template Library (WRL) is a COM-based template library that provides a low-level way to use Windows Runtime components.

The Windows Runtime is implemented by using Component Object Model (COM) technology. COM depends on reference-counting to manage the lifetime of objects, and other housekeeping techniques, and on testing HRESULT values to determine whether an operation succeeded or failed. To successfully write a COM app or library, you must carefully follow COM rules and techniques.

The Visual C++ component extensions (C++/CX) is a high-level, language-based way to use Windows Runtime components. Both the WRL and C++/CX simplify the writing of code for the Windows Runtime by automatically performing COM housekeeping tasks on your behalf.

more

Additional info: Visual C++ WinRT FAQ – WRL vs C++/CX

  • WRL is a non-extension-based ISO compliant alternative to using C++/CX when targeting WinRT. It’s fairly obvious that C++/CX is far simpler to use than WRL, specially when creating components (consuming components is relatively easier).
  • The big thing with WRL is that you can use ISO C++. You don’t have to learn a new syntactic extension that you cannot use outside the Microsoft-world. Most C++ devs would feel comfortable using WRL, specially if they’ve used ATL before. That said portability is a myth, since WRL code is as tied into Windows as would be C++/CX code.
  • Do you want to totally avoid exceptions (perhaps to remain in sync with existing code that doesn’t use exceptions)? If so, you have to use WRL since C++/CX uses exceptions.
  • Performance wise, will you see any difference? As stated above, C++/CX uses exceptions while WRL uses HRESULTs. So the performance implications of using exceptions will obviously come into play. There is also the non-trivial conversion between HRESULTs and RT exceptions. Outide of that, I don’t think there’s going to be any noticable difference in performance.
  • Not sure to what extent you can do this, but since WRL exposes the underlying COM architecture, you can fine-tune your code to some degree (since WinRT is built on top of COM). I haven’t read or heard about any scenarios where this has actually made a difference.
  • The psycological aspect. While this is the least technical of the reasons, it might be the biggest factor here. Many C++ devs would simply hate anything that they see as foreign syntax. And C++/CX is certainly not ISO C++. Its close similarity with C++/CLI (which many C++ devs found disgusting) doesn’t help either. If your C++ dev team comprises mainly of a bunch of these guys, I reckon it’d be wise to just use WRL.

 

Windows 8: Unit testing native code

May 23rd, 2012 No comments

Unit testing native code with Unit Test Explorer

In Visual Studio, you can create unit tests for unmanaged code written in C++. Unmanaged code is sometimes referred to as native code.

The following procedure contains the essential information that will get you started. The later sections provide a walkthrough that describes the steps in more detail.

patterns & practices – Hilo: dev a Windows Metro style app using C++ & XAML

Hilo guides you though the development of a Windows Metro style app. The Hilo sample is a photo viewing and tagging app using C++ and XAML. Hilo demonstrates how to create live tiles, virtualize scrolling, suspend and resume the app, implement search, share and other contracts.

Verifying Code by Using Unit Tests

The Visual Studio 11 unit test tools are designed to support developers and teams who incorporate unit testing in their software development practices. Unit tests give developers and testers a quick way to look for logic errors in the methods of classes in Visual C#, Visual Basic, and Visual C++ projects.