1

As the title suggests I'm trying to build a library ( a small DirectX renderer) to be used both in a Windows8/Metro App, while also be usable for developement of Desktop apps using Win32.

To be more precise I'm wondering if I can use some sort of pre-processor directive to detect the target platform and separate the difference of code between these platforms using them, and if there exist where exactly can I get more information about that.

Deanna
  • 23,876
  • 7
  • 71
  • 156
Taikand
  • 268
  • 1
  • 10
  • 1
    Please check this question http://stackoverflow.com/questions/11961771/macro-to-recognize-winrt – acrilige Mar 17 '13 at 06:06
  • That other question might be for using inside of your own application though. If you create a library - it might be used in either Windows Store or desktop apps - not sure if that macro helps you there. – Filip Skakun Mar 18 '13 at 22:35
  • The pre processor makes compile time changes to code so will allow you to create two different versions. It won't help you detect what environment it's running in. – Deanna Apr 18 '13 at 10:50

1 Answers1

1

You can not, once a library has been build, pre-processor directives are already processed. This is why you would have to build two librarys, one for each purpose.

This link might answer further questions:

http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/61829316-fff3-43c7-a86a-cf0e13c66845/

thewhiteambit
  • 1,365
  • 16
  • 31
  • My comment referred to having those directives compile two different binaries, not having a piece of compiled code that detects at runtime the environment. – Taikand Apr 18 '13 at 18:08