diff --git a/src/threads.h b/src/threads.h
index 4e3866d7e18b475ef225113adfdcf447d59dd184..70282721e1fd2973b1ae301bdc1a34fa1a74a260 100644
--- a/src/threads.h
+++ b/src/threads.h
@@ -288,7 +288,7 @@ struct thread_state {
    SWAP_IN_THREAD(_tmp);\
  } while(0)
 
-#ifdef DEBUG
+#if defined(DEBUG) && ! defined(DONT_HIDE_GLOBALS)
 /* Note that scalar types are used in place of pointers and vice versa
  * below. This is intended to cause compiler warnings/errors if
  * there is an attempt to use the global variables in an unsafe