GENie
GENie copied to clipboard
CompileAsWinRT behavior
I'd love to propose a change to <CompileAsWinRT>
in .vcxproj
generation.
To summarize the current behavior, it looks like this to me:
- If your platform is "Durango" or you've specified the "NoWinRT" flag, the
.vcxproj
's<ClCompile>
section gets<CompileAsWinRT>false</CompileAsWinRT>
. Otherwise it's left unspecified. - If a file has a
.c
extension and the project is for Windows Store or one of its brethren, it gets<CompileAsWinRT>false</CompileAsWinRT>
. - If a file has a
.cx
extension, it gets this entire block:
<CompileAsWinRT>true</CompileAsWinRT>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
A few questions:
1.) Is this behavior around a .cx
extension a common naming convention for files? I searched a bunch but couldn't find anything.
2.) As far as I can tell, it's valid to disable RTTI while compiling as WinRT. Are there known issues that make it get forced on here?
3.) Why no provision for allowing an entire project on Durango to have CompileAsWinRT
on?
For me, I think the ideal change would be to allow a project-wide CompileAsWinRT
for Durango. The file-specific option is interesting, though; it could potentially be extended to a winrt { }
filelist piece of a configuration, instead of relying on a file extension.
I could do the pull request for this, if any changes seem good to you. Thanks!
-
I created
.cx
extension to match behavior of similar files like.mm
,.m
,.c
, etc. so that certain properties can be added to these files. Microsoft recently announced that they are allowing C++ developers to directly call WinRT: https://msdn.microsoft.com/en-us/magazine/mt745094.aspx. My guess, based on previous experience with MS is that they are probably going to discontinue support for C++/CX language extension, since no one really wants to use it. -
RTTI was enabled because of errors I was getting if it's not enabled (I forgot details).
-
Projects using GENie usually have one-to-few
.cx
files, and they directly interface with WinRT, other files call functions provided by these files. It provides nice compartmentalization of platform specific code (in the same way as.mm
/.m
does). Also, my assumption is that no one wants to infect the whole code base with this MS specific CX language extension.
Did you consider moving and wrapping all C++/CX/WinRT specific code into .cx
and accessing that from regular C/C++ code?
As for PR, I would like to preserve current behavior for .cx
files, but you can add project wide CompileAsWinRT
flag if that's what your project really need.
I was reading about C++/WinRT as an alternative to C++/CX while researching this issue! It sounds great, but unfortunately doesn't seem to be available for Durango, so for now I'm left with the ^
-full codebase I have.
I could refactor into .cx
files (and I actually think it's a nice way of doing things), but it'd be a decent-sized refactor to do at this point, especially just while I experiment with this new build system.
If the .cx
behavior stays (which makes sense), would you be ok with removing the Durango-specific forcing of CompileAsWinRT
to false
? It'd make it behave more like the other WinRT platforms, and returning to the old behavior would be as simple as:
configuration { "Durango" }
flags { "NoWinRT" }
Basically you're saying, remove "Durango" from this line and that's it? https://github.com/bkaradzic/GENie/blob/master/src/actions/vstudio/vstudio_vcxproj.lua#L414
I believe that would then at least allow me to add /ZW
to buildoptions
to get the effect I want. Maybe at a later date I could make the transition to individual .cx
files.
For what it's worth, I've just found that Durango headers for C++/WinRT (akin to the Windows ones you linked) became available last month. So maybe this point eventually becomes moot? I haven't tested them to see if they work as expected or cover all my use cases.
Try just adding /ZW
it might work already.
For what it's worth, I've just found that Durango headers for C++/WinRT (akin to the Windows ones you linked) became available last month.
Yeah, knowing MS, they do these massive swings with their tech. First they force everyone to use some tech they made, and if people don't adopt it they just abandon it. So it's always safe to wait a while until they abandon whatever new thing they created. :)
This just got released a few day ago: https://github.com/microsoft/cppwinrt
Oh nice, it looks like they're bringing that into the official Windows SDK this fall. That said, the Durango headers are incomplete and can't completely replace C++/CX, so... ¯\_(ツ)_/¯
Frustrating!