Can I use the C# preprocessor to skip Kinect v2.0 code? -
quick question, i'm developing small program i'd work kinect versions 1 , 2. there preprocessor command can use c# compiler skips kinect v2.0 code if don't have kinect 2.0 sdk installed? (when i'm working on windows 7 example).
basically, this:
#if kinect1 // ... kinect1 specifict code #endif #if kinect2 // ... kinect2 specific code #endif
of course, have define symbols manually, there no builtin capability in compiler or framework detect version available, if @ all.
you might able detect installed kinect sdk (version) using msbuild. example, specific registry keys, paths on local drives and/or set environment variables , set symbols inside project files.
for example, include following fragment on top of .csproj
file (or put separate file <import>
).
<propertygroup condition="exists('c:\program files\...\whatever\v1.0')"> <defineconstants>kinect1;$(defineconstants)</defineconstants> </propertygroup> <propertygroup condition="exists('c:\program files\...\whatever\v2.0')"> <defineconstants>kinect2;$(defineconstants)</defineconstants> </propertygroup>
(mind you, above if example though, no idea "trigger" detect version kinect).
update
@scott chamberlain comment helped. kinect 1.0 sdk sets kinectsdk10_dir
environment variable , 2.0 sdk sets kinectsdk20_dir
envrionment variable.
so, might (this might well):
<propertygroup condition="'$(kinectsdk10_dir)' != '' , exists('$(kinectsdk10_dir)')"> <defineconstants>kinect1;$(defineconstants)</defineconstants> </propertygroup> <propertygroup condition="'$(kinectsdk20_dir)' != '' , exists('$(kinectsdk20_dir)')"> <defineconstants>kinect2;$(defineconstants)</defineconstants> </propertygroup>
Comments
Post a Comment