Macro for detecting Parallels while compiling in MS Visual Studio?

Discussion in 'Windows Virtual Machine' started by DerekS16, Feb 20, 2024.

  1. DerekS16



    I tried searching first, but I didn't find anything nearly relevant to my issue.

    I have a cross-platform project I am working on, but unfortunately the Windows side doesn't execute well. I encounter many illegal instruction exceptions while the exe is running within Parallels. This is fine because when I am using my MacBook to compile/debug in MSVS under Parallels it is because I am "on-the-road", and I have a Windows desktop for extensive work. Almost always I am testing only a very small part of my code while using Parallels. However, sometimes those pieces come AFTER the crashing code, within normal execution.

    I "get by" using a macro in my compile-time environs macros header:
    #define MY_MACRO_PARALLELS_EMULATION 1 // we are compiling in MSVS within Parallels

    However, sometimes I forget to switch the macro to 0 when I move back to my Desktop.

    I am wondering if anyone knows of ideas on how to automatically detect that Paralells is present when compiling under MSVS ( 2022 ). And if so, if they could share them with me. ;P


Share This Page