Address review: use CHAISCRIPT_DEBUG instead of _DEBUG

Switch CHAISCRIPT_DEBUG from a true/false definition to 1/0 so it can
be used in preprocessor #if expressions, then reuse it for the MSVC
Debug guard around CHAISCRIPT_MAX_CALL_DEPTH instead of testing the
compiler-private _DEBUG macro directly. The C++ debug_build constant
keeps its bool value through implicit conversion.

Requested by @lefticus in PR #700 review.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
leftibot 2026-05-02 10:53:47 -06:00
parent ec05fcf3d4
commit bd6fd1f237

View File

@ -70,9 +70,9 @@ static_assert(_MSC_FULL_VER >= 190024210, "Visual C++ 2015 Update 3 or later req
#endif #endif
#ifdef _DEBUG #ifdef _DEBUG
#define CHAISCRIPT_DEBUG true #define CHAISCRIPT_DEBUG 1
#else #else
#define CHAISCRIPT_DEBUG false #define CHAISCRIPT_DEBUG 0
#endif #endif
// Upper bound on the depth of nested ChaiScript function calls. Hitting it // Upper bound on the depth of nested ChaiScript function calls. Hitting it
@ -86,7 +86,7 @@ static_assert(_MSC_FULL_VER >= 190024210, "Visual C++ 2015 Update 3 or later req
// MSVC Release build overflows the native stack before the depth check fires. // MSVC Release build overflows the native stack before the depth check fires.
// We pick a tighter default in that configuration to keep the throw reachable. // We pick a tighter default in that configuration to keep the throw reachable.
#ifndef CHAISCRIPT_MAX_CALL_DEPTH #ifndef CHAISCRIPT_MAX_CALL_DEPTH
#if defined(CHAISCRIPT_MSVC) && defined(_DEBUG) #if defined(CHAISCRIPT_MSVC) && CHAISCRIPT_DEBUG
#define CHAISCRIPT_MAX_CALL_DEPTH 32 #define CHAISCRIPT_MAX_CALL_DEPTH 32
#else #else
#define CHAISCRIPT_MAX_CALL_DEPTH 256 #define CHAISCRIPT_MAX_CALL_DEPTH 256