diff --git a/compiler/main/CodeOutput.hs b/compiler/main/CodeOutput.hs
index 050e6f5c14e66c1bda39ba0fb94ebd5d80189d4a..6f80df967634d9761ef607cb424b859737b59d7d 100644
--- a/compiler/main/CodeOutput.hs
+++ b/compiler/main/CodeOutput.hs
@@ -252,8 +252,8 @@ outputForeignStubs dflags mod location stubs
                                        then Just stub_c
                                        else Nothing )
  where
-   cplusplus_hdr = "#ifdef __cplusplus\nextern \"C\" {\n#endif\n"
-   cplusplus_ftr = "#ifdef __cplusplus\n}\n#endif\n"
+   cplusplus_hdr = "#if defined(__cplusplus)\nextern \"C\" {\n#endif\n"
+   cplusplus_ftr = "#if defined(__cplusplus)\n}\n#endif\n"
 
 
 -- Don't use doOutput for dumping the f. export stubs
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 7009771aa45a5647329aaea5c16653a3009ab841..2315be3519f401140f453649786120b802b18ac5 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -3020,7 +3020,7 @@ dynamic_flags_deps = [
   , make_ord_flag defGhcFlag "rdynamic" $ noArg $
 #if defined(linux_HOST_OS)
                               addOptl "-rdynamic"
-#elif defined (mingw32_HOST_OS)
+#elif defined(mingw32_HOST_OS)
                               addOptl "-Wl,--export-all-symbols"
 #else
     -- ignored for compat w/ gcc:
diff --git a/compiler/utils/Util.hs b/compiler/utils/Util.hs
index aa4afa54513f04c78e416a460b7e9d3f525a78a6..dba5a4495f03aafdaa631bbea9e492f1c6e43654 100644
--- a/compiler/utils/Util.hs
+++ b/compiler/utils/Util.hs
@@ -576,7 +576,7 @@ only _ = panic "Util: only"
 
 isIn, isn'tIn :: Eq a => String -> a -> [a] -> Bool
 
-# ifndef DEBUG
+# if !defined(DEBUG)
 isIn    _msg x ys = x `elem` ys
 isn'tIn _msg x ys = x `notElem` ys
 
diff --git a/docs/coding-style.html b/docs/coding-style.html
index 6be9263d974cc0f3f6fc458fcb5877dc74d5ee93..dbf0f8729a5d01b7ae63d2ec97def79e27d26cb2 100644
--- a/docs/coding-style.html
+++ b/docs/coding-style.html
@@ -88,7 +88,7 @@ together implement a subsystem which is described by a single external
 header file).
 
 <p><li>We use the following GCC extensions, but surround them with
-<tt>#ifdef __GNUC__</tt>:
+<tt>#if defined(__GNUC__)</tt>:
 
 <ul>
 <li>Function attributes (mostly just <code>no_return</code> and
@@ -169,7 +169,7 @@ Instead, add an appropriate test to the configure.ac script and use
 the result of that test instead.
 
 <pre>
-  #ifdef HAVE_BSD_H
+  #if defined(HAVE_BSD_H)
   // use a BSD library
   #endif
 </pre>
@@ -192,10 +192,10 @@ than trying to find a bug which only shows up when running GHC on
 itself and doesn't manifest itself until 10 seconds after the actual
 cause of the problem.
 
-<p>We put all our debugging code inside <tt>#ifdef DEBUG</tt>.  The
+<p>We put all our debugging code inside <tt>#if defined(DEBUG)</tt>.  The
 general policy is we don't ship code with debugging checks and
 assertions in it, but we do run with those checks in place when
-developing and testing.  Anything inside <tt>#ifdef DEBUG</tt> should
+developing and testing.  Anything inside <tt>#if defined(DEBUG)</tt> should
 not slow down the code by more than a factor of 2.
 
 <p>We also have more expensive "sanity checking" code for hardcore
@@ -472,7 +472,7 @@ and by keeping it to 80 columns we can ensure that code looks OK on
 everyone's screen.  Long lines are hard to read, and a sign that the
 code needs to be restructured anyway.
 
-<li> When commenting out large chunks of code, use <code>#ifdef 0
+<li> When commenting out large chunks of code, use <code>#if defined(0)
 ... #endif</code> rather than <code>/* ... */</code> because C doesn't
 have nested comments.
 
diff --git a/docs/storage-mgt/rp.tex b/docs/storage-mgt/rp.tex
index 199b284b19506fbf4dc02f59609bb0b19a0ecaca..ced5c0cd4f37e5560fbd2d748380d15de4bb3aaf 100644
--- a/docs/storage-mgt/rp.tex
+++ b/docs/storage-mgt/rp.tex
@@ -204,7 +204,7 @@ ways of building executable programs from
 source files: normal way and profiling way. 
 We are concerned only about profiling way, and all the pieces of code 
 implementing profiling way are wrapped by the @PROFILING@ 
-pre-processing directive (as in @\#ifdef PROFILING@).
+pre-processing directive (as in @\#if defined(PROFILING)@).
 Therefore, all the additions and changes that we make to the source code 
 are assumed to be wrapped by the @PROFILING@ pre-processing 
 directive as well unless otherwise mentioned.}
diff --git a/libraries/base/System/Environment/Blank.hsc b/libraries/base/System/Environment/Blank.hsc
index 637a0398099bbac316bc86f44d79f8c8ef04f9a7..02d369b5d6ac5c632dce48819979de891e0a8b7b 100644
--- a/libraries/base/System/Environment/Blank.hsc
+++ b/libraries/base/System/Environment/Blank.hsc
@@ -40,7 +40,7 @@ module System.Environment.Blank
   ) where
 
 import Foreign.C
-#ifdef mingw32_HOST_OS
+#if defined(mingw32_HOST_OS)
 import Foreign.Ptr
 import GHC.Windows
 import Control.Monad
@@ -61,7 +61,7 @@ import System.Environment
       withProgName,
       getEnvironment
   )
-#ifndef mingw32_HOST_OS
+#if !defined(mingw32_HOST_OS)
 import qualified System.Environment as Environment
 #endif
 
@@ -85,7 +85,7 @@ throwInvalidArgument from =
 
 -- | Similar to 'System.Environment.lookupEnv'.
 getEnv :: String -> IO (Maybe String)
-#ifdef mingw32_HOST_OS
+#if defined(mingw32_HOST_OS)
 getEnv = (<$> getEnvironment) . lookup
 #else
 getEnv = Environment.lookupEnv
diff --git a/libraries/base/tests/IO/T12010/T12010.hsc b/libraries/base/tests/IO/T12010/T12010.hsc
index e13a5fe5c7652afabd2df9911160a9a77d59e171..9bcb92ef837f9ff250bc3d000b1d4063e1136e33 100644
--- a/libraries/base/tests/IO/T12010/T12010.hsc
+++ b/libraries/base/tests/IO/T12010/T12010.hsc
@@ -7,7 +7,7 @@ import Foreign.Marshal.Alloc
 import GHC.IO.FD
 import System.Exit
 
-#ifdef _WIN32
+#if defined(_WIN32)
 #include <winsock.h>
 #else
 #include <sys/socket.h>
@@ -21,7 +21,7 @@ sOCK_STREAM = #const SOCK_STREAM
 
 main :: IO ()
 main = do
-#ifdef _WIN32
+#if defined(_WIN32)
   void $ initWinSock
 #endif
   sock <- c_socket aF_INET sOCK_STREAM 0
@@ -34,6 +34,6 @@ main = do
 foreign import stdcall unsafe "socket"
   c_socket :: CInt -> CInt -> CInt -> IO CInt
 
-#ifdef _WIN32
+#if defined(_WIN32)
 foreign import ccall unsafe "initWinSock" initWinSock :: IO Int
 #endif
diff --git a/libraries/libiserv/src/GHCi/Utils.hsc b/libraries/libiserv/src/GHCi/Utils.hsc
index b90cfacb5fb060791575775b038287548e9afecb..f606eb9d94658220ed2f288bbbe6c1915dd31322 100644
--- a/libraries/libiserv/src/GHCi/Utils.hsc
+++ b/libraries/libiserv/src/GHCi/Utils.hsc
@@ -5,7 +5,7 @@ module GHCi.Utils
 
 import Foreign.C
 import GHC.IO.Handle (Handle())
-#ifdef mingw32_HOST_OS
+#if defined(mingw32_HOST_OS)
 import GHC.IO.Handle.FD (fdToHandle)
 #else
 import System.Posix
@@ -15,7 +15,7 @@ import System.Posix
 
 -- | Gets a GHC Handle File description from the given OS Handle or POSIX fd.
 getGhcHandle :: CInt -> IO Handle
-#ifdef mingw32_HOST_OS
+#if defined(mingw32_HOST_OS)
 getGhcHandle handle = _open_osfhandle handle (#const _O_BINARY) >>= fdToHandle
 
 foreign import ccall "io.h _open_osfhandle" _open_osfhandle ::
diff --git a/rts/Capability.c b/rts/Capability.c
index bda3b0e681d5ea526079a8e49f8e08fbb76e3756..33a94398cd17705fa7ce9fa2ab8794f2a61f6814 100644
--- a/rts/Capability.c
+++ b/rts/Capability.c
@@ -842,7 +842,7 @@ void waitForCapability (Capability **pCap, Task *task)
  *
  * ------------------------------------------------------------------------- */
 
-#if defined (THREADED_RTS)
+#if defined(THREADED_RTS)
 
 /* See Note [GC livelock] in Schedule.c for why we have gcAllowed
    and return the bool */
@@ -948,7 +948,7 @@ yieldCapability (Capability** pCap, Task *task, bool gcAllowed)
  * get every Capability into the GC.
  * ------------------------------------------------------------------------- */
 
-#if defined (THREADED_RTS)
+#if defined(THREADED_RTS)
 
 void
 prodCapability (Capability *cap, Task *task)
@@ -970,7 +970,7 @@ prodCapability (Capability *cap, Task *task)
  *
  * ------------------------------------------------------------------------- */
 
-#if defined (THREADED_RTS)
+#if defined(THREADED_RTS)
 
 bool
 tryGrabCapability (Capability *cap, Task *task)
diff --git a/rts/Capability.h b/rts/Capability.h
index dc1c6c2073f7c15ad920c3edbb7d2c7a5f94c269..2a5f127793effbfcb0ea4253084ebedd29ce3498 100644
--- a/rts/Capability.h
+++ b/rts/Capability.h
@@ -160,7 +160,7 @@ struct Capability_ {
 } // typedef Capability is defined in RtsAPI.h
   // We never want a Capability to overlap a cache line with anything
   // else, so round it up to a cache line size:
-#ifndef mingw32_HOST_OS
+#if !defined(mingw32_HOST_OS)
   ATTRIBUTE_ALIGNED(64)
 #endif
   ;
diff --git a/rts/Hash.c b/rts/Hash.c
index 658187b944de0a49ecc72334a2362ad6ad3c539c..2f611c9079d99f9cf186ffe0f733966c9bcbd217 100644
--- a/rts/Hash.c
+++ b/rts/Hash.c
@@ -80,7 +80,7 @@ int
 hashStr(const HashTable *table, StgWord w)
 {
     const char *key = (char*) w;
-#ifdef x86_64_HOST_ARCH
+#if defined(x86_64_HOST_ARCH)
     StgWord h = XXH64 (key, strlen(key), 1048583);
 #else
     StgWord h = XXH32 (key, strlen(key), 1048583);
diff --git a/rts/LinkerInternals.h b/rts/LinkerInternals.h
index 75871a5f989de8097b7549936ff3af36b7206a5b..9bdd7530d53768c97c7936d5207b88468a2f6c90 100644
--- a/rts/LinkerInternals.h
+++ b/rts/LinkerInternals.h
@@ -361,7 +361,7 @@ void freeSegments(ObjectCode *oc);
 || defined(openbsd_HOST_OS) || defined(gnu_HOST_OS)
 #  define OBJFORMAT_ELF
 #  include "linker/ElfTypes.h"
-#elif defined (mingw32_HOST_OS)
+#elif defined(mingw32_HOST_OS)
 #  define OBJFORMAT_PEi386
 #  include "linker/PEi386Types.h"
 #elif defined(darwin_HOST_OS) || defined(ios_HOST_OS)
diff --git a/rts/RtsMessages.c b/rts/RtsMessages.c
index a90962e89f54ccafea93679dfca0b375a2ba3db4..6f13580e06af09876c894cce423472e9a9f2751b 100644
--- a/rts/RtsMessages.c
+++ b/rts/RtsMessages.c
@@ -114,7 +114,7 @@ vdebugBelch(const char*s, va_list ap)
 
 #define BUFSIZE 512
 
-#if defined (mingw32_HOST_OS)
+#if defined(mingw32_HOST_OS)
 static int
 isGUIApp(void)
 {
diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
index 7f62643d3cf7f75f652f3782944396e8c4c87163..e34fcf03f5f2a4698423fa9714a23313ff4bf57c 100644
--- a/rts/RtsSymbols.c
+++ b/rts/RtsSymbols.c
@@ -49,7 +49,7 @@
       SymE_HasProto(libdwPoolRelease)           \
       SymE_HasProto(libdwPoolClear)
 
-#if !defined (mingw32_HOST_OS)
+#if !defined(mingw32_HOST_OS)
 #define RTS_POSIX_ONLY_SYMBOLS                  \
       SymI_HasProto(__hscore_get_saved_termios) \
       SymI_HasProto(__hscore_set_saved_termios) \
diff --git a/rts/StgCRunAsm.S b/rts/StgCRunAsm.S
index 9274a445b5168ac38ed75293aae4d169432d0c19..1dd74d365216f8a74ac25f1b09f8cbed36204c96 100644
--- a/rts/StgCRunAsm.S
+++ b/rts/StgCRunAsm.S
@@ -2,7 +2,7 @@
 #include "rts/Constants.h"
 
 #if defined(powerpc64le_HOST_ARCH)
-# ifdef linux_HOST_OS
+# if defined(linux_HOST_OS)
 # define STACK_FRAME_SIZE RESERVED_C_STACK_BYTES+304
 	.file	"StgCRun.c"
 	.abiversion 2
diff --git a/rts/Ticky.c b/rts/Ticky.c
index 55df113d5db1bad30374758915c435f3bc5d388b..a0611fe4c435b6f658055bc6590ea9299878b550 100644
--- a/rts/Ticky.c
+++ b/rts/Ticky.c
@@ -25,7 +25,7 @@ StgEntCounter *ticky_entry_ctrs = NULL; /* root of list of them */
 /* We want Haskell code compiled with -ticky to be linkable with any
  * version of the RTS, so we have to make sure all the symbols that
  * ticky-compiled code may refer to are defined by every RTS. (#3439)
- * Hence the #ifdef is here, rather than up above.
+ * Hence the #if defined(is) here, rather than up above.
  */
 #if defined(TICKY_TICKY)
 
diff --git a/rts/Trace.c b/rts/Trace.c
index e345377eef0ad6958fad6e21fcd8c826a199c701..d5c431907617f77495488872a237bd4c9b64a4c0 100644
--- a/rts/Trace.c
+++ b/rts/Trace.c
@@ -458,7 +458,7 @@ void traceOSProcessInfo_(void) {
                         CAPSET_OSPROCESS_DEFAULT,
                         getpid());
 
-#if !defined (mingw32_HOST_OS)
+#if !defined(mingw32_HOST_OS)
 /* Windows has no strong concept of process hierarchy, so no getppid().
  * In any case, this trace event is mainly useful for tracing programs
  * that use 'forkProcess' which Windows doesn't support anyway.
diff --git a/rts/linker/ELFRelocs/AArch64.def b/rts/linker/ELFRelocs/AArch64.def
index c21df07d2dbc8f0efae3513ce428705738da5fe5..d77b681dc658c6374a9faf6f99888363e0da8569 100644
--- a/rts/linker/ELFRelocs/AArch64.def
+++ b/rts/linker/ELFRelocs/AArch64.def
@@ -1,5 +1,5 @@
 
-#ifndef ELF_RELOC
+#if !defined(ELF_RELOC)
 #error "ELF_RELOC must be defined"
 #endif
 
diff --git a/rts/linker/ELFRelocs/ARM.def b/rts/linker/ELFRelocs/ARM.def
index 730fc5b8836c8015e4f49ab73b9c6fcb3a70623b..eb21e6cef6e57dcd9a18279effff526b7c09cc9b 100644
--- a/rts/linker/ELFRelocs/ARM.def
+++ b/rts/linker/ELFRelocs/ARM.def
@@ -1,5 +1,5 @@
 
-#ifndef ELF_RELOC
+#if !defined(ELF_RELOC)
 #error "ELF_RELOC must be defined"
 #endif
 
diff --git a/rts/linker/ELFRelocs/i386.def b/rts/linker/ELFRelocs/i386.def
index 1d28cf595cd5cd49ef195d9b3580803dca8b4b16..3191195ea8d2319503205149d77387cb4c0126ec 100644
--- a/rts/linker/ELFRelocs/i386.def
+++ b/rts/linker/ELFRelocs/i386.def
@@ -1,5 +1,5 @@
 
-#ifndef ELF_RELOC
+#if !defined(ELF_RELOC)
 #error "ELF_RELOC must be defined"
 #endif
 
diff --git a/rts/linker/ELFRelocs/x86_64.def b/rts/linker/ELFRelocs/x86_64.def
index 18fdcf9472dc48074c972cdc83fde686c88d2ded..197931fa510ca3cebc5950712f9f64e5688789db 100644
--- a/rts/linker/ELFRelocs/x86_64.def
+++ b/rts/linker/ELFRelocs/x86_64.def
@@ -1,5 +1,5 @@
 
-#ifndef ELF_RELOC
+#if !defined(ELF_RELOC)
 #error "ELF_RELOC must be defined"
 #endif
 
diff --git a/rts/linker/Elf.c b/rts/linker/Elf.c
index 954993f0865ec1236f01b3f574fdb8ac3b89b551..0882f8d34974d8d65c60baae1e9c20d5b47d44fa 100644
--- a/rts/linker/Elf.c
+++ b/rts/linker/Elf.c
@@ -1122,13 +1122,13 @@ do_Elf_Rel_relocations ( ObjectCode* oc, char* ehdrC,
 #endif
 
        switch (reloc_type) {
-#        ifdef i386_HOST_ARCH
+#        if defined(i386_HOST_ARCH)
        case COMPAT_R_386_NONE:                  break;
        case COMPAT_R_386_32:   *pP = value;     break;
        case COMPAT_R_386_PC32: *pP = value - P; break;
 #        endif
 
-#        ifdef arm_HOST_ARCH
+#        if defined(arm_HOST_ARCH)
        case COMPAT_R_ARM_ABS32:     /* (S + A) | T */
            // Specified by Linux ARM ABI to be equivalent to ABS32
        case COMPAT_R_ARM_TARGET1:
diff --git a/rts/linker/ElfTypes.h b/rts/linker/ElfTypes.h
index 852d82a498f2a8bb02a39840fece19fb286c7941..e5333d71a7b0a0049fe93e3e5e5acb92482b1d1d 100644
--- a/rts/linker/ElfTypes.h
+++ b/rts/linker/ElfTypes.h
@@ -1,4 +1,4 @@
-#ifndef ElfTypes_h
+#if !defined(ElfTypes_h)
 #define ElfTypes_h
 
 #if defined(OBJFORMAT_ELF)
diff --git a/rts/linker/elf_compat.h b/rts/linker/elf_compat.h
index c42f1f89494e5f7ec548c01425146ca01bc42938..b409728a09a8150aa920b283a8b682bda6bdfa9c 100644
--- a/rts/linker/elf_compat.h
+++ b/rts/linker/elf_compat.h
@@ -9,7 +9,7 @@
 // under which it is distrubuted.
 //
 
-#ifndef RTS_ELF_COMPAT_H
+#if !defined(RTS_ELF_COMPAT_H)
 #define RTS_ELF_COMPAT_H
 
 #define PASTE(x,y) x ## y
diff --git a/rts/linker/elf_util.h b/rts/linker/elf_util.h
index d94eb6992e74978532b98746281f068ca80a2f3f..2ece19826823d64d6d76797f52232cd56a997b36 100644
--- a/rts/linker/elf_util.h
+++ b/rts/linker/elf_util.h
@@ -1,4 +1,4 @@
-#ifndef RTS_LINKER_ELF_UTIL_H
+#if !defined(RTS_LINKER_ELF_UTIL_H)
 #define RTS_LINKER_ELF_UTIL_H
 
 #include "LinkerInternals.h"
diff --git a/rts/linker/util.h b/rts/linker/util.h
index f2aa50649da20313afc1da82cfd8692f71981293..77f06978abf88b3d22288ab283b20939e353d4ec 100644
--- a/rts/linker/util.h
+++ b/rts/linker/util.h
@@ -1,4 +1,4 @@
-#ifndef RTS_LINKER_UTIL_H
+#if !defined(RTS_LINKER_UTIL_H)
 #define RTS_LINKER_UTIL_H
 
 #include <stdint.h>
diff --git a/rts/package.conf.in b/rts/package.conf.in
index dc44b74ac1e6fc0a3aa88e3fc9f753656f5b4fec..a0e124a061b7cc2544f1e53b208cc13045874b34 100644
--- a/rts/package.conf.in
+++ b/rts/package.conf.in
@@ -55,7 +55,7 @@ extra-libraries:
                               ,"bfd", "iberty"  /* for debugging */
 #endif
 #if defined(HAVE_LIBMINGWEX)
-# ifndef INSTALLING                             /* Bundled Mingw is behind */
+# if !defined(INSTALLING)                             /* Bundled Mingw is behind */
                               ,"mingwex"
 # endif
 #endif
diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c
index cf4b705d7443d8b026173a3f61847e3ce7935263..dc8c4122f7f84db3a112bdb75e5f4cab240a9c12 100644
--- a/rts/posix/OSMem.c
+++ b/rts/posix/OSMem.c
@@ -49,17 +49,17 @@
 #include <sys/sysctl.h>
 #endif
 
-#ifndef MAP_FAILED
+#if !defined(MAP_FAILED)
 # define MAP_FAILED ((void *)-1)
 #endif
 
 #if defined(hpux_HOST_OS)
-# ifndef MAP_ANON
+# if !defined(MAP_ANON)
 #  define MAP_ANON MAP_ANONYMOUS
 # endif
 #endif
 
-#ifndef darwin_HOST_OS
+#if !defined(darwin_HOST_OS)
 # undef RESERVE_FLAGS
 # if defined(MAP_GUARD)
 #  define RESERVE_FLAGS  MAP_GUARD /* FreeBSD */
diff --git a/rts/posix/Select.c b/rts/posix/Select.c
index 211d47dbece06f45866948176b91a1724c21f189..5b143e1bf741258640a17d1a415435c410a5ea63 100644
--- a/rts/posix/Select.c
+++ b/rts/posix/Select.c
@@ -23,11 +23,11 @@
 #include "Stats.h"
 #include "GetTime.h"
 
-# ifdef HAVE_SYS_SELECT_H
+# if defined(HAVE_SYS_SELECT_H)
 #  include <sys/select.h>
 # endif
 
-# ifdef HAVE_SYS_TYPES_H
+# if defined(HAVE_SYS_TYPES_H)
 #  include <sys/types.h>
 # endif
 
diff --git a/rts/win32/ConsoleHandler.c b/rts/win32/ConsoleHandler.c
index 545a76a004db81ca49971ec745b9c29f978d69c6..3ddf4103da34f520a53a27fe3463fa0cc2846b2e 100644
--- a/rts/win32/ConsoleHandler.c
+++ b/rts/win32/ConsoleHandler.c
@@ -37,7 +37,7 @@ void
 initUserSignals(void)
 {
     console_handler = STG_SIG_DFL;
-#if !defined (THREADED_RTS)
+#if !defined(THREADED_RTS)
     stg_pending_events = 0;
     if (hConsoleEvent == INVALID_HANDLE_VALUE) {
         hConsoleEvent =
@@ -59,7 +59,7 @@ freeSignalHandlers(void) {
 void
 finiUserSignals(void)
 {
-#if !defined (THREADED_RTS)
+#if !defined(THREADED_RTS)
     if (hConsoleEvent != INVALID_HANDLE_VALUE) {
         CloseHandle(hConsoleEvent);
     }
@@ -162,7 +162,7 @@ void awaitUserSignals(void)
 }
 
 
-#if !defined (THREADED_RTS)
+#if !defined(THREADED_RTS)
 /*
  * Function: startSignalHandlers()
  *
diff --git a/rts/xxhash.c b/rts/xxhash.c
index 833b99f3b2147ed9e0bf90e25119eb3d89a80fcd..fd63ba89ddd82c2b16345e06316d4c8f6375e0df 100644
--- a/rts/xxhash.c
+++ b/rts/xxhash.c
@@ -49,7 +49,7 @@
  * See http://stackoverflow.com/a/32095106/646947 for details.
  * Prefer these methods in priority order (0 > 1 > 2)
  */
-#ifndef XXH_FORCE_MEMORY_ACCESS   /* can be defined externally, on command line for example */
+#if !defined(XXH_FORCE_MEMORY_ACCESS)   /* can be defined externally, on command line for example */
 #  if defined(__GNUC__) && ( defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) )
 #    define XXH_FORCE_MEMORY_ACCESS 2
 #  elif defined(__INTEL_COMPILER) || \
@@ -73,7 +73,7 @@
  * to improve speed for Big-endian CPU.
  * This option has no impact on Little_Endian CPU.
  */
-#ifndef XXH_FORCE_NATIVE_FORMAT   /* can be defined externally */
+#if !defined(XXH_FORCE_NATIVE_FORMAT)   /* can be defined externally */
 #  define XXH_FORCE_NATIVE_FORMAT 0
 #endif
 
@@ -84,7 +84,7 @@
  * set it to 0 when the input is guaranteed to be aligned,
  * or when alignment doesn't matter for performance.
  */
-#ifndef XXH_FORCE_ALIGN_CHECK /* can be defined externally */
+#if !defined(XXH_FORCE_ALIGN_CHECK) /* can be defined externally */
 #  if defined(__i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64)
 #    define XXH_FORCE_ALIGN_CHECK 0
 #  else
@@ -112,12 +112,12 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcp
 /* *************************************
 *  Compiler Specific Options
 ***************************************/
-#ifdef _MSC_VER    /* Visual Studio */
+#if defined(_MSC_VER)    /* Visual Studio */
 #  pragma warning(disable : 4127)      /* disable: C4127: conditional expression is constant */
 #  define FORCE_INLINE static __forceinline
 #else
-#  if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L   /* C99 */
-#    ifdef __GNUC__
+#  if defined(__cplusplus) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L   /* C99 */
+#    if defined(__GNUC__)
 #      define FORCE_INLINE static inline __attribute__((always_inline))
 #    else
 #      define FORCE_INLINE static inline
@@ -131,8 +131,8 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcp
 /* *************************************
 *  Basic Types
 ***************************************/
-#ifndef MEM_MODULE
-# if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
+#if !defined(MEM_MODULE)
+# if !defined(__VMS) && (defined(__cplusplus) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
 #   include <stdint.h>
     typedef uint8_t  BYTE;
     typedef uint16_t U16;
@@ -206,7 +206,7 @@ static U32 XXH_swap32 (U32 x)
 typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess;
 
 /* XXH_CPU_LITTLE_ENDIAN can be defined externally, for example on the compiler command line */
-#ifndef XXH_CPU_LITTLE_ENDIAN
+#if !defined(XXH_CPU_LITTLE_ENDIAN)
     static const int g_one = 1;
 #   define XXH_CPU_LITTLE_ENDIAN   (*(const char*)(&g_one))
 #endif
@@ -267,7 +267,7 @@ FORCE_INLINE U32 XXH32_endian_align(const void* input, size_t len, U32 seed, XXH
     U32 h32;
 #define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
 
-#ifdef XXH_ACCEPT_NULL_INPUT_POINTER
+#if defined(XXH_ACCEPT_NULL_INPUT_POINTER)
     if (p==NULL) {
         len=0;
         bEnd=p=(const BYTE*)(size_t)16;
@@ -380,7 +380,7 @@ FORCE_INLINE XXH_errorcode XXH32_update_endian (XXH32_state_t* state, const void
     const BYTE* p = (const BYTE*)input;
     const BYTE* const bEnd = p + len;
 
-#ifdef XXH_ACCEPT_NULL_INPUT_POINTER
+#if defined(XXH_ACCEPT_NULL_INPUT_POINTER)
     if (input==NULL) return XXH_ERROR;
 #endif
 
@@ -513,7 +513,7 @@ XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src
 }
 
 
-#ifndef XXH_NO_LONG_LONG
+#if !defined(XXH_NO_LONG_LONG)
 
 /* *******************************************************************
 *  64-bits hash functions
@@ -521,9 +521,9 @@ XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src
 
 /*======   Memory access   ======*/
 
-#ifndef MEM_MODULE
+#if !defined(MEM_MODULE)
 # define MEM_MODULE
-# if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
+# if !defined(__VMS) && (defined(__cplusplus) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
 #   include <stdint.h>
     typedef uint64_t U64;
 # else
@@ -627,7 +627,7 @@ FORCE_INLINE U64 XXH64_endian_align(const void* input, size_t len, U64 seed, XXH
     U64 h64;
 #define XXH_get64bits(p) XXH_readLE64_align(p, endian, align)
 
-#ifdef XXH_ACCEPT_NULL_INPUT_POINTER
+#if defined(XXH_ACCEPT_NULL_INPUT_POINTER)
     if (p==NULL) {
         len=0;
         bEnd=p=(const BYTE*)(size_t)32;
@@ -749,7 +749,7 @@ FORCE_INLINE XXH_errorcode XXH64_update_endian (XXH64_state_t* state, const void
     const BYTE* p = (const BYTE*)input;
     const BYTE* const bEnd = p + len;
 
-#ifdef XXH_ACCEPT_NULL_INPUT_POINTER
+#if defined(XXH_ACCEPT_NULL_INPUT_POINTER)
     if (input==NULL) return XXH_ERROR;
 #endif
 
diff --git a/rts/xxhash.h b/rts/xxhash.h
index 9d831e03b35f6b3d5410a186cedeb95dc45e52f8..98ec9639cb87d816189b6c815b6424b995e0fa9b 100644
--- a/rts/xxhash.h
+++ b/rts/xxhash.h
@@ -64,10 +64,10 @@ XXH64       13.8 GB/s            1.9 GB/s
 XXH32        6.8 GB/s            6.0 GB/s
 */
 
-#ifndef XXHASH_H_5627135585666179
+#if !defined(XXHASH_H_5627135585666179)
 #define XXHASH_H_5627135585666179 1
 
-#if defined (__cplusplus)
+#if defined(__cplusplus)
 extern "C" {
 #endif
 
@@ -91,13 +91,13 @@ typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode;
 *   `xxhash.c` is automatically included.
 *   It's not useful to compile and link it as a separate module.
 */
-#ifdef XXH_PRIVATE_API
-#  ifndef XXH_STATIC_LINKING_ONLY
+#if defined(XXH_PRIVATE_API)
+#  if !defined(XXH_STATIC_LINKING_ONLY)
 #    define XXH_STATIC_LINKING_ONLY
 #  endif
 #  if defined(__GNUC__)
 #    define XXH_PUBLIC_API static __inline __attribute__((unused))
-#  elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
+#  elif defined(__cplusplus) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
 #    define XXH_PUBLIC_API static inline
 #  elif defined(_MSC_VER)
 #    define XXH_PUBLIC_API static __inline
@@ -119,7 +119,7 @@ with the value of XXH_NAMESPACE (therefore, avoid NULL and numeric values).
 Note that no change is required within the calling program as long as it includes `xxhash.h` :
 regular symbol name will be automatically translated by this header.
 */
-#ifdef XXH_NAMESPACE
+#if defined(XXH_NAMESPACE)
 #  define XXH_CAT(A,B) A##B
 #  define XXH_NAME2(A,B) XXH_CAT(A,B)
 #  define XXH_versionNumber XXH_NAME2(XXH_NAMESPACE, XXH_versionNumber)
@@ -211,7 +211,7 @@ XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src
 */
 
 
-#ifndef XXH_NO_LONG_LONG
+#if !defined(XXH_NO_LONG_LONG)
 /*-**********************************************************************
 *  64-bits hash
 ************************************************************************/
@@ -241,7 +241,7 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src
 #endif  /* XXH_NO_LONG_LONG */
 
 
-#ifdef XXH_STATIC_LINKING_ONLY
+#if defined(XXH_STATIC_LINKING_ONLY)
 
 /* ================================================================================================
    This section contains definitions which are not guaranteed to remain stable.
@@ -266,7 +266,7 @@ struct XXH32_state_s {
    unsigned reserved;   /* never read nor write, will be removed in a future version */
 };   /* typedef'd to XXH32_state_t */
 
-#ifndef XXH_NO_LONG_LONG   /* remove 64-bits support */
+#if !defined(XXH_NO_LONG_LONG)   /* remove 64-bits support */
 struct XXH64_state_s {
    unsigned long long total_len;
    unsigned long long v1;
@@ -279,14 +279,14 @@ struct XXH64_state_s {
 };   /* typedef'd to XXH64_state_t */
 #endif
 
-#ifdef XXH_PRIVATE_API
+#if defined(XXH_PRIVATE_API)
 #  include "xxhash.c"   /* include xxhash function bodies as `static`, for inlining */
 #endif
 
 #endif /* XXH_STATIC_LINKING_ONLY */
 
 
-#if defined (__cplusplus)
+#if defined(__cplusplus)
 }
 #endif
 
diff --git a/testsuite/tests/codeGen/should_run/T7600.hs b/testsuite/tests/codeGen/should_run/T7600.hs
index 9f0e118b4431bc803e57300a341d9ad06997517e..4193fdc33f169b205b36bc9625c931be1067584e 100644
--- a/testsuite/tests/codeGen/should_run/T7600.hs
+++ b/testsuite/tests/codeGen/should_run/T7600.hs
@@ -103,7 +103,7 @@ main = test_run float_number double_number
 --     in  "0x" ++ str
 -- 
 -- fixEndian :: [a] -> [a]
--- -- #ifdef WORDS_BIGENDIAN
+-- -- #if defined(WORDS_BIGENDIAN)
 -- -- fixEndian = id
 -- -- #else
 -- fixEndian = reverse
diff --git a/testsuite/tests/codeGen/should_run/cgrun044.hs b/testsuite/tests/codeGen/should_run/cgrun044.hs
index 17811f110a1afeae3fc05e4696f4da73d625f2fe..f5f39398952fa1924e9db3a29e571fb7f2fe7aa3 100644
--- a/testsuite/tests/codeGen/should_run/cgrun044.hs
+++ b/testsuite/tests/codeGen/should_run/cgrun044.hs
@@ -11,7 +11,7 @@ import Data.Array.ST
 #include "ghcconfig.h"
 
 reverse_if_bigendian :: [a] -> [a]
-#ifdef WORDS_BIGENDIAN
+#if defined(WORDS_BIGENDIAN)
 reverse_if_bigendian = reverse
 #else
 reverse_if_bigendian = id
diff --git a/testsuite/tests/concurrent/should_run/conc036.hs b/testsuite/tests/concurrent/should_run/conc036.hs
index 528649ce56a2476a14814fabde3b69c0ffb1ea6a..6bfee0336a8c8bc77db5552f6b94e7ad80348543 100644
--- a/testsuite/tests/concurrent/should_run/conc036.hs
+++ b/testsuite/tests/concurrent/should_run/conc036.hs
@@ -8,7 +8,7 @@ import Prelude hiding (catch)
 import Foreign
 import System.IO
 
-#ifdef mingw32_HOST_OS
+#if defined(mingw32_HOST_OS)
 sleep n = sleepBlock (n*1000)
 foreign import stdcall unsafe "Sleep" sleepBlock :: Int -> IO ()
 #else
diff --git a/testsuite/tests/concurrent/should_run/conc037.hs b/testsuite/tests/concurrent/should_run/conc037.hs
index 7da76f50259fceb0170c243262a961bcbf85d51c..6f6d5e2d0af8eb1fbf6a8a01c15dcb8e22333410 100644
--- a/testsuite/tests/concurrent/should_run/conc037.hs
+++ b/testsuite/tests/concurrent/should_run/conc037.hs
@@ -4,7 +4,7 @@ module Main where
 
 import Control.Concurrent
 
-#ifdef mingw32_HOST_OS
+#if defined(mingw32_HOST_OS)
 foreign import stdcall safe "Sleep" _sleepBlock :: Int -> IO ()
 sleepBlock n = _sleepBlock (n*1000)
 #else
diff --git a/testsuite/tests/concurrent/should_run/conc038.hs b/testsuite/tests/concurrent/should_run/conc038.hs
index e4489e1cf3ccf8c883642c08948db8deb4963192..bf7fd6d261a3d6afb810bcff5ca1a3100ca5ec1f 100644
--- a/testsuite/tests/concurrent/should_run/conc038.hs
+++ b/testsuite/tests/concurrent/should_run/conc038.hs
@@ -10,7 +10,7 @@ haskellFun c = putStrLn ("Haskell: " ++ show c)
 foreign export ccall "hFun"  haskellFun :: Int -> IO ()
 foreign import ccall safe "hFun"  hFun :: Int -> IO ()
 
-#ifdef mingw32_HOST_OS
+#if defined(mingw32_HOST_OS)
 foreign import stdcall safe "Sleep" _sleepBlock :: Int -> IO ()
 sleepBlock n = _sleepBlock (n*1000)
 #else
diff --git a/testsuite/tests/concurrent/should_run/conc059.hs b/testsuite/tests/concurrent/should_run/conc059.hs
index 148c0ba63d979089931d9a7447bdc96edf5723b6..86e202c9a2bfb1ff8373e961e6bb260bbd4d9a50 100644
--- a/testsuite/tests/concurrent/should_run/conc059.hs
+++ b/testsuite/tests/concurrent/should_run/conc059.hs
@@ -18,7 +18,7 @@ f x = do
 
 foreign export ccall "f" f :: Int -> IO ()
 
-#ifdef mingw32_HOST_OS
+#if defined(mingw32_HOST_OS)
 # if defined(i386_HOST_ARCH)
 #  define WINDOWS_CCONV stdcall
 # elif defined(x86_64_HOST_ARCH)
diff --git a/testsuite/tests/concurrent/should_run/foreignInterruptible.hs b/testsuite/tests/concurrent/should_run/foreignInterruptible.hs
index 73585ec43b2c4c5a348240a5bad10df038263d07..6cd18388ed3d0afff9231e0184552e935a8fb46e 100644
--- a/testsuite/tests/concurrent/should_run/foreignInterruptible.hs
+++ b/testsuite/tests/concurrent/should_run/foreignInterruptible.hs
@@ -6,7 +6,7 @@ import Control.Exception
 import Foreign
 import System.IO
 
-#ifdef mingw32_HOST_OS
+#if defined(mingw32_HOST_OS)
 sleep n = sleepBlock (n*1000)
 foreign import stdcall interruptible "Sleep" sleepBlock :: Int -> IO ()
 #else
diff --git a/testsuite/tests/driver/T11763.hs b/testsuite/tests/driver/T11763.hs
index 3fd5df9fce00c8f5a3a10c08368e16ecf934318e..6fcb4b97b5eedf60b5b49974c0480a271eb43a7e 100644
--- a/testsuite/tests/driver/T11763.hs
+++ b/testsuite/tests/driver/T11763.hs
@@ -1,5 +1,5 @@
 {-# LANGUAGE CPP #-}
 main = do
-#ifndef VERSION_containers
+#if !defined(VERSION_containers)
     putStrLn "OK"
 #endif
diff --git a/testsuite/tests/driver/T2464.hs b/testsuite/tests/driver/T2464.hs
index 6bee708e4be749559dd646d7bdcc15cd73613bb1..84a7c03ccad7bff1a6e37a21b790c754beba0efe 100644
--- a/testsuite/tests/driver/T2464.hs
+++ b/testsuite/tests/driver/T2464.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE CPP #-}
 {-# OPTIONS_GHC -DTEST #-}
 {-# OPTIONS_GHC -fffi #-} -- deprecation warning
-#ifdef TEST
+#if defined(TEST)
 {-# LANGUAGE EmptyDataDecls #-}
 #endif
 
diff --git a/testsuite/tests/ffi/should_compile/T11983.h b/testsuite/tests/ffi/should_compile/T11983.h
index 33c78cb9a4699fa92daecbbec9336fe73b3fb545..c4b0a2038cbd98978fff7e316512559b33fcdde5 100644
--- a/testsuite/tests/ffi/should_compile/T11983.h
+++ b/testsuite/tests/ffi/should_compile/T11983.h
@@ -1,4 +1,4 @@
-#ifndef T11983_H
+#if !defined(T11983_H)
 #define T11983_H
 
 #include <stdint.h>
diff --git a/testsuite/tests/ffi/should_run/capi_ctype_001.h b/testsuite/tests/ffi/should_run/capi_ctype_001.h
index 11add5bf3d3e67dff9f0ae87362118cf58747ccf..a51f030aa700733983fec471a7ff1685871f6a7c 100644
--- a/testsuite/tests/ffi/should_run/capi_ctype_001.h
+++ b/testsuite/tests/ffi/should_run/capi_ctype_001.h
@@ -1,5 +1,5 @@
 
-#ifndef __capi_ctype_001_H__
+#if !defined(__capi_ctype_001_H__)
 #define __capi_ctype_001_H__
 
 typedef struct {
diff --git a/testsuite/tests/ffi/should_run/capi_ctype_002_A.h b/testsuite/tests/ffi/should_run/capi_ctype_002_A.h
index 26928a3436cec97a8571f685abef639bd42483b0..e6b5dc05046fa7d9487721c088f13d47ba20e131 100644
--- a/testsuite/tests/ffi/should_run/capi_ctype_002_A.h
+++ b/testsuite/tests/ffi/should_run/capi_ctype_002_A.h
@@ -1,5 +1,5 @@
 
-#ifndef __capi_ctype_002_A_H__
+#if !defined(__capi_ctype_002_A_H__)
 #define __capi_ctype_002_A_H__
 
 typedef struct {
diff --git a/testsuite/tests/ffi/should_run/capi_ctype_002_B.h b/testsuite/tests/ffi/should_run/capi_ctype_002_B.h
index 6928290f47da82de6699a25a893ae4b994c927e3..fb6cef8caf1396cb4325cdba1cfa5e935ee21dfa 100644
--- a/testsuite/tests/ffi/should_run/capi_ctype_002_B.h
+++ b/testsuite/tests/ffi/should_run/capi_ctype_002_B.h
@@ -1,5 +1,5 @@
 
-#ifndef __capi_ctype_002_B_H__
+#if !defined(__capi_ctype_002_B_H__)
 #define __capi_ctype_002_B_H__
 
 #define f(p) p->j
diff --git a/testsuite/tests/ffi/should_run/fptr01.h b/testsuite/tests/ffi/should_run/fptr01.h
index b50cc417768f36ec42d6794315a8393d1db33cf8..8862c9b9ce226592316aae694defca17cd58db28 100644
--- a/testsuite/tests/ffi/should_run/fptr01.h
+++ b/testsuite/tests/ffi/should_run/fptr01.h
@@ -1,4 +1,4 @@
-#ifndef FPTR01_H_INCLUDED
+#if !defined(FPTR01_H_INCLUDED)
 #define FPTR01_H_INCLUDED
 
 void f( HsInt * );
diff --git a/testsuite/tests/ffi/should_run/fptrfail01.h b/testsuite/tests/ffi/should_run/fptrfail01.h
index 3e10d8bd7a14305bdbb20e19ae9cabbc288a3000..a1611b300ae1a40e98def5df0daf1f6c26989b42 100644
--- a/testsuite/tests/ffi/should_run/fptrfail01.h
+++ b/testsuite/tests/ffi/should_run/fptrfail01.h
@@ -1,4 +1,4 @@
-#ifndef FPTRFAIL01_H_INCLUDED
+#if !defined(FPTRFAIL01_H_INCLUDED)
 #define FPTRFAIL01_H_INCLUDED
 
 void f( HsInt * );
diff --git a/testsuite/tests/hsc2hs/T10272.h b/testsuite/tests/hsc2hs/T10272.h
index 6d8142d9092d996f5458b269111312d71cf4b7b2..1f3d724930ead69cee83ea648c6c7938c943ef24 100644
--- a/testsuite/tests/hsc2hs/T10272.h
+++ b/testsuite/tests/hsc2hs/T10272.h
@@ -1,4 +1,4 @@
-#ifndef _T10272_H_
+#if !defined(_T10272_H_)
 #define _T10272_H_
 
 #include <stdint.h>
diff --git a/testsuite/tests/indexed-types/should_compile/T12538.hs b/testsuite/tests/indexed-types/should_compile/T12538.hs
index 9aff36e47d0e3175d1f08f36168c0f3f73a9da31..4347197486a5a1c9f330dfd54cb616df3d5b3f9c 100644
--- a/testsuite/tests/indexed-types/should_compile/T12538.hs
+++ b/testsuite/tests/indexed-types/should_compile/T12538.hs
@@ -20,7 +20,7 @@ class (r ~ Tag a) => TagImpl a r | a -> r where
 instance {-# OVERLAPPING #-} (r ~ Tag (Tagged t a)) => TagImpl (Tagged t a) r where
   tag = id
 
-#ifdef WRONG
+#if defined(WRONG)
 instance {-# OVERLAPPING #-} (r ~ Tagged t a, r ~ Tag a) => TagImpl a r where
 #else
 instance {-# OVERLAPPING #-} (r ~ Tagged Int a, r ~ Tag a) => TagImpl a r where
diff --git a/testsuite/tests/rename/should_fail/T9032.hs b/testsuite/tests/rename/should_fail/T9032.hs
index 0a00ba37b033a1993881cd75f88150a102601111..2b62aa21fbd7dc2112921661b0e856031043603d 100644
--- a/testsuite/tests/rename/should_fail/T9032.hs
+++ b/testsuite/tests/rename/should_fail/T9032.hs
@@ -2,7 +2,7 @@
 
 module T9032 where
 
-#ifdef ERR
+#if defined(ERR)
 import T9032
 #endif
 
diff --git a/testsuite/tests/rts/T12031/foo.h b/testsuite/tests/rts/T12031/foo.h
index d3ca4aad2d17621337b067f880227108b0beec34..ce205b2c73199a3c2bfaf0834ef65617d82e5017 100644
--- a/testsuite/tests/rts/T12031/foo.h
+++ b/testsuite/tests/rts/T12031/foo.h
@@ -1,6 +1,6 @@
 // Copyright (c) 2016, Ryan Scott
 // foo.h
-#ifndef FOO_H
+#if !defined(FOO_H)
 #define FOO_H
 
 extern int foo;
diff --git a/testsuite/tests/rts/spalign.c b/testsuite/tests/rts/spalign.c
index 0b776e17ccae968126a96c1e13a7f0cc69ec998f..fe615eecbd1ac1b613746cdb5fe367b7ca8ce839 100644
--- a/testsuite/tests/rts/spalign.c
+++ b/testsuite/tests/rts/spalign.c
@@ -1,12 +1,12 @@
 #include "Rts.h"
 
-#ifdef darwin_HOST_OS
+#if defined(darwin_HOST_OS)
 #define STG_GLOBAL ".globl "
 #else
 #define STG_GLOBAL ".global "
 #endif
 
-#ifdef LEADING_UNDERSCORE
+#if defined(LEADING_UNDERSCORE)
 #define GETESP "_getesp"
 #else
 #define GETESP "getesp"
diff --git a/testsuite/tests/rts/testheapalloced.c b/testsuite/tests/rts/testheapalloced.c
index a28079572a7b16253f3656873e600f780175fe2b..240f787c144179dafafa4d3b182c9e018ae16de9 100644
--- a/testsuite/tests/rts/testheapalloced.c
+++ b/testsuite/tests/rts/testheapalloced.c
@@ -1,10 +1,10 @@
 #include "Rts.h"
 #include "RtsFlags.h"
-#ifdef DEBUG
+#if defined(DEBUG)
 #define INLINE_HEADER
 #endif
 #include "MBlock.h"
-#ifdef DEBUG
+#if defined(DEBUG)
 extern void *getFirstMBlock(void);
 extern void *getNextMBlock(void *mblock);
 #endif
@@ -42,7 +42,7 @@ int main (int argc, char *argv[])
         a[j] = allocGroup_lock(rand() % MAXALLOC + 1);
     }
 
-#ifdef DEBUG
+#if defined(DEBUG)
     {
         void *p;
         i = 0;
diff --git a/testsuite/tests/rts/testwsdeque.c b/testsuite/tests/rts/testwsdeque.c
index 0a2a64d78e1bab69f775c1ec37949861382ce31c..8d3a88cf57ea298c6298800729a5d504bcbb7e2f 100644
--- a/testsuite/tests/rts/testwsdeque.c
+++ b/testsuite/tests/rts/testwsdeque.c
@@ -18,7 +18,7 @@ OSThreadId ids[THREADS];
 // -----------------------------------------------------------------------------
 // version of stealWSDeque() that logs its actions, for debugging
 
-#ifdef DEBUG
+#if defined(DEBUG)
 
 #define BUF 128
 
@@ -128,7 +128,7 @@ void OSThreadProcAttr thief(void *info)
     n = (StgWord)info;
 
     while (!done) {
-#ifdef DEBUG
+#if defined(DEBUG)
         p = myStealWSDeque(q,n);
 #else
         p = stealWSDeque(q);
@@ -163,7 +163,7 @@ int main(int argc, char*argv[])
         pushWSDeque(q,&scratch[n]);
     }
 
-#ifdef DEBUG
+#if defined(DEBUG)
     debugBelch("main thread finished, popped %d", count);
 #endif
     exit(0);
diff --git a/testsuite/tests/simplCore/T9646/cbits/primitive-memops.h b/testsuite/tests/simplCore/T9646/cbits/primitive-memops.h
index 700ef05a8d0dab30ed75cc9353874781263fb526..cfafbb4f6d87f007f29b8154174a0354ab80c3f4 100644
--- a/testsuite/tests/simplCore/T9646/cbits/primitive-memops.h
+++ b/testsuite/tests/simplCore/T9646/cbits/primitive-memops.h
@@ -1,4 +1,4 @@
-#ifndef haskell_primitive_memops_h
+#if !defined(haskell_primitive_memops_h)
 #define haskell_primitive_memops_h
 
 #include <stdlib.h>
diff --git a/testsuite/tests/simplCore/should_compile/T8832.hs b/testsuite/tests/simplCore/should_compile/T8832.hs
index db5e3a78b63a1d04bc243af13c85a469a755e814..0cbff6976b75910103d580e759fd3edeabda001b 100644
--- a/testsuite/tests/simplCore/should_compile/T8832.hs
+++ b/testsuite/tests/simplCore/should_compile/T8832.hs
@@ -17,7 +17,7 @@ T(i,Int)
 T(i8,Int8)
 T(i16,Int16)
 T(i32,Int32)
-#ifdef T8832_WORDSIZE_64
+#if defined(T8832_WORDSIZE_64)
 T(i64,Int64)
 #endif
 
@@ -25,7 +25,7 @@ T(w,Word)
 T(w8,Word8)
 T(w16,Word16)
 T(w32,Word32)
-#ifdef T8832_WORDSIZE_64
+#if defined(T8832_WORDSIZE_64)
 T(w64,Word64)
 #endif
 
diff --git a/testsuite/tests/typecheck/should_run/T1735.hs b/testsuite/tests/typecheck/should_run/T1735.hs
index 8a23c9effe424b3768b715482f0ef6ad8c37f11e..44dc54197ab6039faadcdb51ae528b0f0f14121f 100644
--- a/testsuite/tests/typecheck/should_run/T1735.hs
+++ b/testsuite/tests/typecheck/should_run/T1735.hs
@@ -41,7 +41,7 @@ mkMyListConstr = mkConstr myListDataType "MkMyList" [] Prefix
 myListDataType :: DataType
 myListDataType = mkDataType "MyList" [mkMyListConstr]
 
-#ifdef FOO
+#if defined(FOO)
 rigidTests :: Maybe (Maybe [YesNo])
 rigidTests =
  mkTest [Elem "No"  []] (Just [No])
diff --git a/testsuite/tests/typecheck/should_run/T1735_Help/Main.hs b/testsuite/tests/typecheck/should_run/T1735_Help/Main.hs
index 0c59d449fa12dfcefbd3d23bd716765adc09c334..15dd583c6e381b4c688308e0936d00a30e517a40 100644
--- a/testsuite/tests/typecheck/should_run/T1735_Help/Main.hs
+++ b/testsuite/tests/typecheck/should_run/T1735_Help/Main.hs
@@ -42,7 +42,7 @@ mkMyListConstr = mkConstr myListDataType "MkMyList" [] Prefix
 myListDataType :: DataType
 myListDataType = mkDataType "MyList" [mkMyListConstr]
 
-#ifdef FOO
+#if defined(FOO)
 rigidTests :: Maybe (Maybe [YesNo])
 rigidTests =
  mkTest [Elem "No"  []] (Just [No])
diff --git a/utils/iserv/src/Main.hs b/utils/iserv/src/Main.hs
index 858cee8e94fda882ffccab4e820755151b404d29..15ea9f50304004808857624bf1a6a8b95bc4f56f 100644
--- a/utils/iserv/src/Main.hs
+++ b/utils/iserv/src/Main.hs
@@ -26,7 +26,7 @@ dieWithUsage = do
     prog <- getProgName
     die $ prog ++ ": " ++ msg
   where
-#ifdef WINDOWS
+#if defined(WINDOWS)
     msg = "usage: iserv <write-handle> <read-handle> [-v]"
 #else
     msg = "usage: iserv <write-fd> <read-fd> [-v]"