diff --git a/changelog.md b/changelog.md
--- a/changelog.md
+++ b/changelog.md
@@ -1,3 +1,5 @@
+- 0.5.4.1: Do not generate C code when haddock is type checking.  See
+  issue #24.
 - 0.5.4.0: Allow Haskell identifiers in anti-quotes.  See issue #23.
 - 0.5.3.4: Fix `bsCtx` docs.
 - 0.5.3.3:
diff --git a/examples/gsl-ode.c b/examples/gsl-ode.c
--- a/examples/gsl-ode.c
+++ b/examples/gsl-ode.c
@@ -10,7 +10,7 @@
 }
 
 
-int inline_c_1_47df0b9eb63f3a30404e3c62c19a67e120afdfc6(int (* funIO_inline_c_0)(double t, const double y[], double dydt[], void * params), int dim_c_inline_c_1, double x0_inline_c_2, double xend_inline_c_3, double * fMut_inline_c_4) {
+int inline_c_1_a6e274e32d1c2e90339edd389a8b86d3fe8dae07(int (* funIO_inline_c_0)(double t, const double y[], double dydt[], void * params), int dim_c_inline_c_1, double x0_inline_c_2, double xend_inline_c_3, double * fMut_inline_c_4) {
 
       gsl_odeiv2_system sys = {
         funIO_inline_c_0,
diff --git a/inline-c.cabal b/inline-c.cabal
--- a/inline-c.cabal
+++ b/inline-c.cabal
@@ -1,5 +1,5 @@
 name:                inline-c
-version:             0.5.4.0
+version:             0.5.4.1
 synopsis:            Write Haskell source files including C code inline. No FFI required.
 description:         See <https://github.com/fpco/inline-c/blob/master/README.md>.
 license:             MIT
diff --git a/src/Language/C/Inline.hs b/src/Language/C/Inline.hs
--- a/src/Language/C/Inline.hs
+++ b/src/Language/C/Inline.hs
@@ -8,8 +8,6 @@
 {-# LANGUAGE TypeFamilies #-}
 {-# LANGUAGE TypeOperators #-}
 
-{-# OPTIONS_GHC -fno-warn-orphans #-} -- This is used for IsString C.Id
-
 -- | Enable painless embedding of C code in Haskell code. If you're interested
 -- in how to use the library, skip to the "Inline C" section. To build, read the
 -- first two sections.
diff --git a/src/Language/C/Inline/Context.hs b/src/Language/C/Inline/Context.hs
--- a/src/Language/C/Inline/Context.hs
+++ b/src/Language/C/Inline/Context.hs
@@ -50,7 +50,6 @@
 import           Data.Int (Int8, Int16, Int32, Int64)
 import qualified Data.Map as Map
 import           Data.Monoid ((<>))
-import           Data.Traversable (traverse)
 import           Data.Typeable (Typeable)
 import qualified Data.Vector.Storable as V
 import qualified Data.Vector.Storable.Mutable as VM
@@ -64,6 +63,7 @@
 
 #if __GLASGOW_HASKELL__ < 710
 import           Data.Monoid (Monoid(..))
+import           Data.Traversable (traverse)
 #endif
 
 import           Language.C.Inline.FunPtr
diff --git a/src/Language/C/Inline/HaskellIdentifier.hs b/src/Language/C/Inline/HaskellIdentifier.hs
--- a/src/Language/C/Inline/HaskellIdentifier.hs
+++ b/src/Language/C/Inline/HaskellIdentifier.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 {-# LANGUAGE ConstraintKinds #-}
 {-# LANGUAGE DeriveDataTypeable #-}
 {-# LANGUAGE FlexibleContexts #-}
@@ -12,8 +13,7 @@
   , mangleHaskellIdentifier
   ) where
 
-import           Control.Applicative ((<*), (<$>))
-import           Control.Applicative ((<|>), (<*>))
+import           Control.Applicative ((<|>))
 import           Control.Monad (when, msum, void)
 import           Data.Char (ord)
 import qualified Data.HashSet as HashSet
@@ -31,6 +31,10 @@
 import qualified Text.PrettyPrint.ANSI.Leijen as PP
 
 import qualified Language.C.Types.Parse as C
+
+#if __GLASGOW_HASKELL__ < 710
+import           Control.Applicative ((<*), (<$>), (<*>))
+#endif
 
 -- | A possibly qualified Haskell identifier.
 newtype HaskellIdentifier = HaskellIdentifier {unHaskellIdentifier :: String}
diff --git a/src/Language/C/Inline/Internal.hs b/src/Language/C/Inline/Internal.hs
--- a/src/Language/C/Inline/Internal.hs
+++ b/src/Language/C/Inline/Internal.hs
@@ -75,6 +75,7 @@
 import qualified Text.Parser.Token as Parser
 import           Text.PrettyPrint.ANSI.Leijen ((<+>))
 import qualified Text.PrettyPrint.ANSI.Leijen as PP
+import           System.Environment (getProgName)
 
 import           Language.C.Inline.Context
 import           Language.C.Inline.FunPtr
@@ -112,7 +113,7 @@
   -- 'baseCtx' will be used.
   -> TH.Q Context
 initialiseModuleState mbContext = do
-  cFile <- cSourceLoc context
+  mbcFile <- cSourceLoc context
   thisModule <- getModuleId
   TH.runIO $ modifyMVar moduleStatesVar $ \moduleStates -> do
     case Map.lookup thisModule moduleStates of
@@ -121,7 +122,7 @@
         -- If the file exists and this is the first time we write
         -- something from this module (in other words, if we are
         -- recompiling the module), kill the file first.
-        removeIfExists cFile
+        forM_ mbcFile $ \cFile -> removeIfExists cFile
         let moduleState = ModuleState
               { msContext = context
               , msGeneratedNames = 0
@@ -172,11 +173,22 @@
 ------------------------------------------------------------------------
 -- Emitting
 
-cSourceLoc :: Context -> TH.Q FilePath
+-- | Return the path in which to emit C code. Or 'Nothing' if emitting should be
+-- inhibited, say because we're only type checking the module, not emitting code
+-- (e.g. with @-fno-code@ or in @haddock@)
+cSourceLoc :: Context -> TH.Q (Maybe FilePath)
 cSourceLoc ctx = do
-  thisFile <- TH.loc_filename <$> TH.location
-  let ext = fromMaybe "c" $ ctxFileExtension ctx
-  return $ dropExtension thisFile `addExtension` ext
+    thisFile <- TH.loc_filename <$> TH.location
+    let ext = fromMaybe "c" $ ctxFileExtension ctx
+    emitCode <- TH.runIO $ do
+      prog <- getProgName
+      -- Hard-code a common case for not generating code.  haddock just
+      -- type-checks, so we do not need to generate the C file again.
+      -- See issue #24.
+      return $ prog /= "haddock"
+    return $ if emitCode
+      then Just $ dropExtension thisFile `addExtension` ext
+      else Nothing
 
 removeIfExists :: FilePath -> IO ()
 removeIfExists fileName = removeFile fileName `catch` handleExists
@@ -187,8 +199,10 @@
 emitVerbatim :: String -> TH.DecsQ
 emitVerbatim s = do
   ctx <- getContext
-  cFile <- cSourceLoc ctx
-  TH.runIO $ appendFile cFile $ "\n" ++ s ++ "\n"
+  mbCFile <- cSourceLoc ctx
+  case mbCFile of
+    Nothing -> return ()
+    Just cFile -> TH.runIO $ appendFile cFile $ "\n" ++ s ++ "\n"
   return []
 
 ------------------------------------------------------------------------
diff --git a/src/Language/C/Types.hs b/src/Language/C/Types.hs
--- a/src/Language/C/Types.hs
+++ b/src/Language/C/Types.hs
@@ -63,18 +63,18 @@
 import           Control.Arrow (second)
 import           Control.Monad (when, unless, forM_)
 import           Control.Monad.State (execState, modify)
-import           Data.Foldable (Foldable)
 import           Data.List (partition)
 import           Data.Maybe (fromMaybe)
 import           Data.Monoid ((<>))
-import           Data.Traversable (Traversable)
 import           Data.Typeable (Typeable)
 import           Text.PrettyPrint.ANSI.Leijen ((</>), (<+>))
 import qualified Text.PrettyPrint.ANSI.Leijen as PP
 
 #if __GLASGOW_HASKELL__ < 710
+import           Data.Foldable (Foldable)
 import           Data.Functor ((<$>))
 import           Data.Monoid (Monoid(..))
+import           Data.Traversable (Traversable)
 #endif
 
 import qualified Language.C.Types.Parse as P
diff --git a/src/Language/C/Types/Parse.hs b/src/Language/C/Types/Parse.hs
--- a/src/Language/C/Types/Parse.hs
+++ b/src/Language/C/Types/Parse.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 {-# LANGUAGE ConstraintKinds #-}
 {-# LANGUAGE DeriveDataTypeable #-}
 {-# LANGUAGE DeriveFoldable #-}
@@ -89,14 +90,12 @@
 import           Control.Applicative
 import           Control.Monad (msum, void, MonadPlus, unless, when)
 import           Control.Monad.Reader (MonadReader, runReaderT, ReaderT, asks, ask)
-import           Data.Foldable (Foldable)
 import           Data.Functor.Identity (Identity)
 import qualified Data.HashSet as HashSet
 import           Data.Hashable (Hashable)
 import           Data.Maybe (mapMaybe)
 import           Data.Monoid ((<>))
 import           Data.String (IsString(..))
-import           Data.Traversable (Traversable)
 import           Data.Typeable (Typeable)
 import qualified Test.QuickCheck as QC
 import qualified Text.Parsec as Parsec
@@ -107,6 +106,11 @@
 import qualified Text.Parser.Token.Highlight as Highlight
 import           Text.PrettyPrint.ANSI.Leijen (Pretty(..), (<+>), Doc, hsep)
 import qualified Text.PrettyPrint.ANSI.Leijen as PP
+
+#if __GLASGOW_HASKELL__ < 710
+import           Data.Foldable (Foldable)
+import           Data.Traversable (Traversable)
+#endif
 
 ------------------------------------------------------------------------
 -- Config
