Always use appropriate preprocessor directives to guard platform-specific, version-dependent, or feature-specific code. Ensure that conditional compilation checks accurately reflect the actual availability of features and APIs, not just version numbers or single configuration flags.

When gating functionality:

Example of proper conditional compilation:

#ifdef TREE_SITTER_FEATURE_WASM
// WASM-specific code that requires __builtin_wasm_memory_size
#endif

#if PY_MINOR_VERSION >= 13 && !defined(Py_GIL_DISABLED)
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
#endif

#elif !defined(__wasi__)
// Platform-specific implementation
#else
// WASI fallback or noop implementation
#endif

This prevents compilation errors across different environments and ensures code portability while maintaining feature availability where supported.