diff --git a/build.rs b/build.rs index 27e7f8f0..4489b3ff 100644 --- a/build.rs +++ b/build.rs @@ -131,5 +131,7 @@ fn main() { .extra_warnings(false) .compile("winptywrapper"); - println!("cargo:rustc-link-lib=dylib=winpty"); + if winpty_enabled == "1" { + println!("cargo:rustc-link-lib=dylib=winpty"); + } } diff --git a/include/StackWalker.h b/include/StackWalker.h index 9821f35d..14c8ba04 100644 --- a/include/StackWalker.h +++ b/include/StackWalker.h @@ -1,5 +1,5 @@ -#ifdef DEBUG +#if DEBUG #ifndef __STACKWALKER_H__ #define __STACKWALKER_H__ diff --git a/include/common.h b/include/common.h index dfe1d5b6..fcca5d49 100644 --- a/include/common.h +++ b/include/common.h @@ -13,13 +13,13 @@ #include -#ifdef ENABLE_WINPTY +#if ENABLE_WINPTY static constexpr bool WINPTY_ENABLED = true; #else static constexpr bool WINPTY_ENABLED = false; #endif // ENABLE_WINPTY -#ifdef ENABLE_CONPTY +#if ENABLE_CONPTY static constexpr bool CONPTY_ENABLED = true; #else static constexpr bool CONPTY_ENABLED = false; diff --git a/include/winpty_common.h b/include/winpty_common.h index 21b0067d..6ce215a8 100644 --- a/include/winpty_common.h +++ b/include/winpty_common.h @@ -2,7 +2,8 @@ #include "base.h" -#ifdef ENABLE_WINPTY +#if ENABLE_WINPTY + extern "C" { #include #include diff --git a/src/csrc/StackWalker.cpp b/src/csrc/StackWalker.cpp index 8291fb29..a0bbed39 100644 --- a/src/csrc/StackWalker.cpp +++ b/src/csrc/StackWalker.cpp @@ -82,7 +82,7 @@ * **********************************************************************/ -#ifdef DEBUG +#if DEBUG #include "StackWalker.h" #include diff --git a/src/csrc/conpty_common.cpp b/src/csrc/conpty_common.cpp index a0cfaa31..ba56c1c3 100644 --- a/src/csrc/conpty_common.cpp +++ b/src/csrc/conpty_common.cpp @@ -7,7 +7,7 @@ Native ConPTY calls. See: https://docs.microsoft.com/en-us/windows/console/creating-a-pseudoconsole-session **/ -#ifdef ENABLE_CONPTY +#if ENABLE_CONPTY HRESULT SetUpPseudoConsole(HPCON* hPC, COORD size, HANDLE* inputReadSide, HANDLE* outputWriteSide, HANDLE* outputReadSide, HANDLE* inputWriteSide) { diff --git a/src/csrc/pty.cpp b/src/csrc/pty.cpp index c1bce10e..62445e9b 100644 --- a/src/csrc/pty.cpp +++ b/src/csrc/pty.cpp @@ -1,6 +1,6 @@ #include "pty.h" -#ifdef DEBUG +#if DEBUG // Debug utilities used to print a stack trace // In order to use it: // MyStackWalker sw; sw.ShowCallstack(); diff --git a/src/csrc/winpty_common.cpp b/src/csrc/winpty_common.cpp index 0cee51fe..a115ecd6 100644 --- a/src/csrc/winpty_common.cpp +++ b/src/csrc/winpty_common.cpp @@ -1,6 +1,6 @@ #include "winpty_common.h" -#ifdef ENABLE_WINPTY +#if ENABLE_WINPTY void compose_error_message(winpty_error_ptr_t err, char* tmp) { std::wstring err_msg = winpty_error_msg(err); std::wstring err_code = std::to_wstring(winpty_error_code(err));