diff --git a/CHANGELOG b/CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+Version 1.18
+------------
+  * better lexing of Template Haskell single quotes (thanks to Stephan Wehr)
+
 Version 1.17
 ------------
   * recursively evaluate #if expressions after macro expansion (fix)
diff --git a/Language/Preprocessor/Cpphs/Tokenise.hs b/Language/Preprocessor/Cpphs/Tokenise.hs
--- a/Language/Preprocessor/Cpphs/Tokenise.hs
+++ b/Language/Preprocessor/Cpphs/Tokenise.hs
@@ -106,8 +106,14 @@
                                             haskell CLineComment "  " p ls xs
   haskell Any acc p ls ('"':xs)           = emit acc $
                                             haskell (String '"') ['"'] p ls xs
-  haskell Any acc p ls ('\'':xs)          = emit acc $
+  haskell Any acc p ls ('\'':'\'':xs)     = emit acc $ -- TH type quote
+                                            haskell Any "''" p ls xs
+  haskell Any acc p ls ('\'':xs@('\\':_)) = emit acc $ -- escaped char literal
                                             haskell (String '\'') "'" p ls xs
+  haskell Any acc p ls ('\'':x:'\'':xs)   = emit acc $ -- character literal
+                                            haskell Any ['\'', x, '\''] p ls xs
+  haskell Any acc p ls ('\'':xs)          = emit acc $ -- TH name quote
+                                            haskell Any "'" p ls xs
   haskell Any acc p ls (x:xs) | single x  = emit acc $ emit [x] $
                                             haskell Any [] p ls xs
   haskell Any acc p ls (x:xs) | space x   = emit acc $
@@ -272,4 +278,3 @@
     args n w acc (x@(Other _)  :xs)  = args n     (x:w)         acc    xs
     args _ _ _   _                   = Nothing
     addone w acc = reverse (skip w): acc
-
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 LIBRARY = cpphs
-VERSION = 1.17.1
+VERSION = 1.18
 
 DIRS	= Language/Preprocessor/Cpphs \
 	  Text/ParserCombinators
diff --git a/cpphs.cabal b/cpphs.cabal
--- a/cpphs.cabal
+++ b/cpphs.cabal
@@ -1,5 +1,5 @@
 Name: cpphs
-Version: 1.17.1
+Version: 1.18
 Copyright: 2004-2013, Malcolm Wallace
 License: LGPL
 License-File: LICENCE-LGPL
diff --git a/cpphs.hs b/cpphs.hs
--- a/cpphs.hs
+++ b/cpphs.hs
@@ -20,7 +20,7 @@
 import Data.List   ( isPrefixOf )
 
 version :: String
-version = "1.17.1"
+version = "1.18"
 
 main :: IO ()
 main = do
diff --git a/docs/index.html b/docs/index.html
--- a/docs/index.html
+++ b/docs/index.html
@@ -198,11 +198,11 @@
 <b>Current stable version:</b>
 
 <p>
-cpphs-1.17.1, release date 2013.08.18<br>
+cpphs-1.18, release date 2014.02.04<br>
 By HTTP:
 <a href="http://hackage.haskell.org/package/cpphs">Hackage</a>.
 <ul>
-<li> (minor) Report the correct version number with <tt>cpphs --version</tt>
+<li> Better lexing of Template Haskell single quotes.  (Thanks to Stephan Wehr)
 </ul>
 
 <p>
@@ -226,6 +226,15 @@
 <b>Older versions:</b>
 
 
+
+
+<p>
+cpphs-1.17.1, release date 2013.08.18<br>
+By HTTP:
+<a href="http://hackage.haskell.org/package/cpphs">Hackage</a>.
+<ul>
+<li> (minor) Report the correct version number with <tt>cpphs --version</tt>
+</ul>
 
 <p>
 cpphs-1.17, release date 2013.08.16<br>
diff --git a/tests/expect56 b/tests/expect56
new file mode 100644
--- /dev/null
+++ b/tests/expect56
@@ -0,0 +1,6 @@
+#line 1 "th"
+
+test_b = FOO False
+-- This line causes troubles:
+SafeCopy.deriveSafeCopy 0 'SafeCopy.base ''Event
+test_a = FOO True
diff --git a/tests/runtests b/tests/runtests
--- a/tests/runtests
+++ b/tests/runtests
@@ -73,4 +73,5 @@
 runtest "$CPPHS --nomacro --strip-eol nomacro" expect53
 runtest "$CPPHS --strip-eol nomacro" expect54
 runtest "$CPPHS ballard" expect55
+runtest "$CPPHS th" expect56
 exit $FAIL
diff --git a/tests/th b/tests/th
new file mode 100644
--- /dev/null
+++ b/tests/th
@@ -0,0 +1,5 @@
+#define assertBool FOO
+test_b = assertBool False
+-- This line causes troubles:
+SafeCopy.deriveSafeCopy 0 'SafeCopy.base ''Event
+test_a = assertBool True
