{"id":105940,"date":"2021-11-18T07:00:00","date_gmt":"2021-11-18T15:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=105940"},"modified":"2021-11-18T06:46:52","modified_gmt":"2021-11-18T14:46:52","slug":"20211118-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20211118-00\/?p=105940","title":{"rendered":"What does the CompileAsWinRT Visual Studio project option mean?"},"content":{"rendered":"<p>A customer was investigating some build problems in their C++\/WinRT project related to mismatches in the state of <code>WINRT_<wbr \/>NO_<wbr \/>MAKE_<wbr \/>DETECTION<\/code>. Along the way, they found that in their project file, they did not set <code>CompileAsWinRT<\/code> to <code>true<\/code>. Is that a problem?<\/p>\n<p>The <code>CompileAsWinRT<\/code> property controls whether the Microsoft C++ compiler enables C++\/CX language extensions. It corresponds to the command line switch <code>\/ZW<\/code>. This is confirmed by the <code>cl.xml<\/code> file buried deep inside Visual Studio:<\/p>\n<pre>  &lt;BoolProperty\r\n        Name=\"CompileAsWinRT\"\r\n        DisplayName=\"Consume Windows Runtime Extension\"\r\n        Description=\"Consume the Windows Run Time languages extensions.  (\/ZW)\"\r\n        Category=\"General\"\r\n        Switch=\"ZW\"\r\n        F1Keyword=\"VC.Project.VCCLCompilerTool.CompileAsWinRT\"&gt;\r\n  &lt;\/BoolProperty&gt;\r\n<\/pre>\n<p>(I like how they spelled it as <i>Run Time<\/i> in the description, but used the compound word <i>Runtime<\/i> in the display name.)<\/p>\n<p>C++\/CX was the first projection of the Windows Runtime into C++, so it got first dibs and took the good name. It&#8217;s now a decade later, and C++\/CX is no longer the Windows Runtime projection of choice, but the name of the property can&#8217;t be changed for compatibility reasons.<\/p>\n<p>So don&#8217;t worry, you don&#8217;t need to (and indeed shouldn&#8217;t) turn on <code>CompileAsWinRT<\/code> for your C++\/WinRT projects. Turning it on enables the old-and-busted projection of the Windows Runtime.<\/p>\n<p><b>Bonus chatter<\/b>: So what&#8217;s the compiler switch to enable C++\/WinRT?<\/p>\n<p>That&#8217;s a trick question. There is no special compiler switch needed because C++\/WinRT is written in standard C++. No nonstandard language extensions are required. Just include the C++\/WinRT header files and go.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>And why it&#8217;s badly-named.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-105940","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>And why it&#8217;s badly-named.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/105940","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=105940"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/105940\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=105940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=105940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=105940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}