diff --git a/Foreign/CUDA/Driver/Context.chs b/Foreign/CUDA/Driver/Context.chs
--- a/Foreign/CUDA/Driver/Context.chs
+++ b/Foreign/CUDA/Driver/Context.chs
@@ -2,7 +2,7 @@
 {-# LANGUAGE CPP                      #-}
 {-# LANGUAGE EmptyDataDecls           #-}
 {-# LANGUAGE ForeignFunctionInterface #-}
-#if MIN_VERSION_base(4,7,0)
+#ifdef USE_EMPTY_CASE
 {-# LANGUAGE EmptyCase                #-}
 #endif
 --------------------------------------------------------------------------------
@@ -90,7 +90,7 @@
 --
 data PeerFlag
 instance Enum PeerFlag where
-#if MIN_VERSION_base(4,7,0)
+#ifdef USE_EMPTY_CASE
   toEnum   x = case x of {}
   fromEnum x = case x of {}
 #endif
diff --git a/Foreign/CUDA/Driver/Device.chs b/Foreign/CUDA/Driver/Device.chs
--- a/Foreign/CUDA/Driver/Device.chs
+++ b/Foreign/CUDA/Driver/Device.chs
@@ -2,7 +2,7 @@
 {-# LANGUAGE CPP                      #-}
 {-# LANGUAGE EmptyDataDecls           #-}
 {-# LANGUAGE ForeignFunctionInterface #-}
-#if MIN_VERSION_base(4,7,0)
+#ifdef USE_EMPTY_CASE
 {-# LANGUAGE EmptyCase                #-}
 #endif
 --------------------------------------------------------------------------------
@@ -116,7 +116,7 @@
 --
 data InitFlag
 instance Enum InitFlag where
-#if MIN_VERSION_base(4,7,0)
+#ifdef USE_EMPTY_CASE
   toEnum   x = case x of {}
   fromEnum x = case x of {}
 #endif
diff --git a/Foreign/CUDA/Runtime/Device.chs b/Foreign/CUDA/Runtime/Device.chs
--- a/Foreign/CUDA/Runtime/Device.chs
+++ b/Foreign/CUDA/Runtime/Device.chs
@@ -3,7 +3,7 @@
 {-# LANGUAGE EmptyDataDecls           #-}
 {-# LANGUAGE ForeignFunctionInterface #-}
 {-# OPTIONS_GHC -fno-warn-orphans #-}
-#if MIN_VERSION_base(4,7,0)
+#ifdef USE_EMPTY_CASE
 {-# LANGUAGE EmptyCase                #-}
 #endif
 --------------------------------------------------------------------------------
@@ -325,7 +325,7 @@
 --
 data PeerFlag
 instance Enum PeerFlag where
-#if MIN_VERSION_base(4,7,0)
+#ifdef USE_EMPTY_CASE
   toEnum   x = case x of {}
   fromEnum x = case x of {}
 #endif
diff --git a/Foreign/CUDA/Types.chs b/Foreign/CUDA/Types.chs
--- a/Foreign/CUDA/Types.chs
+++ b/Foreign/CUDA/Types.chs
@@ -1,7 +1,7 @@
 {-# LANGUAGE BangPatterns   #-}
 {-# LANGUAGE CPP            #-}
 {-# LANGUAGE EmptyDataDecls #-}
-#if MIN_VERSION_base(4,7,0)
+#ifdef USE_EMPTY_CASE
 {-# LANGUAGE EmptyCase      #-}
 #endif
 --------------------------------------------------------------------------------
@@ -106,7 +106,7 @@
 --
 data WaitFlag
 instance Enum WaitFlag where
-#if MIN_VERSION_base(4,7,0)
+#ifdef USE_EMPTY_CASE
   toEnum   x = case x of {}
   fromEnum x = case x of {}
 #endif
@@ -132,7 +132,7 @@
 --
 data StreamFlag
 instance Enum StreamFlag where
-#if MIN_VERSION_base(4,7,0)
+#ifdef USE_EMPTY_CASE
   toEnum   x = case x of {}
   fromEnum x = case x of {}
 #endif
diff --git a/changelog.md b/changelog.md
--- a/changelog.md
+++ b/changelog.md
@@ -1,3 +1,7 @@
+0.6.6.2
+
+  * Build fix
+
 0.6.6.1
 
   * Build fixes for ghc-7.6 and ghc-7.10
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -3208,7 +3208,25 @@
 esac
 LDFLAGS+=" -L${cuda_lib_path} "
 
+# Check what version of GHC we have. Depending on the version, we can enable
+# certain extensions. We can't just use the macros from the cabal_macros.h file
+# as would usually be done, because this file will be in different locations
+# depending on whether we are a regular or sandbox build.
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking ghc version" >&5
+$as_echo_n "checking ghc version... " >&6; }
+target_ghc_version=`${GHC} --numeric-version`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${target_ghc_version}" >&5
+$as_echo "${target_ghc_version}" >&6; }
 
+GHC_VERSION_MAJOR=${target_ghc_version%%.*}
+GHC_VERSION_MINOR=${target_ghc_version#*.}
+GHC_VERSION_MINOR=${GHC_VERSION_MINOR%%.*}
+
+if test ${GHC_VERSION_MAJOR} -gt 7 -o ${GHC_VERSION_MAJOR} -eq 7 -a ${GHC_VERSION_MINOR} -ge 8 ; then
+    cuda_c2hsflags+="--cppopts=-DUSE_EMPTY_CASE "
+fi
+
 # The CUDA headers need to be interpreted relative to the architecture GHC is
 # compiled for, which might be different from the architecture of the host
 # machine (eg. 32-bit GHC on a 64-bit CPU).
@@ -3246,10 +3264,6 @@
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
-
-# Also include any cabal generated macros in the CPP configuration step
-#
-cuda_c2hsflags+="--cppopts=-include=dist/build/autogen/cabal_macros.h "
 
 # Make sure both the driver and runtime are found
 #
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -86,7 +86,23 @@
 esac
 LDFLAGS+=" -L${cuda_lib_path} "
 
+# Check what version of GHC we have. Depending on the version, we can enable
+# certain extensions. We can't just use the macros from the cabal_macros.h file
+# as would usually be done, because this file will be in different locations
+# depending on whether we are a regular or sandbox build.
+#
+AC_MSG_CHECKING(ghc version)
+target_ghc_version=`${GHC} --numeric-version`
+AC_MSG_RESULT(${target_ghc_version})
 
+GHC_VERSION_MAJOR=${target_ghc_version%%.*}
+GHC_VERSION_MINOR=${target_ghc_version#*.}
+GHC_VERSION_MINOR=${GHC_VERSION_MINOR%%.*}
+
+if test ${GHC_VERSION_MAJOR} -gt 7 -o ${GHC_VERSION_MAJOR} -eq 7 -a ${GHC_VERSION_MINOR} -ge 8 ; then
+    cuda_c2hsflags+="--cppopts=-DUSE_EMPTY_CASE "
+fi
+
 # The CUDA headers need to be interpreted relative to the architecture GHC is
 # compiled for, which might be different from the architecture of the host
 # machine (eg. 32-bit GHC on a 64-bit CPU).
@@ -119,10 +135,6 @@
 else
     AC_MSG_RESULT(no)
 fi
-
-# Also include any cabal generated macros in the CPP configuration step
-#
-cuda_c2hsflags+="--cppopts=-include=dist/build/autogen/cabal_macros.h "
 
 # Make sure both the driver and runtime are found
 #
diff --git a/cuda.cabal b/cuda.cabal
--- a/cuda.cabal
+++ b/cuda.cabal
@@ -1,5 +1,5 @@
 Name:                   cuda
-Version:                0.6.6.1
+Version:                0.6.6.2
 Synopsis:               FFI binding to the CUDA interface for programming NVIDIA GPUs
 Description:
     The CUDA library provides a direct, general purpose C-like SPMD programming
