Index: c2hs-0.16.0/src/C2HS/C/Info.hs
===================================================================
--- c2hs-0.16.0.orig/src/C2HS/C/Info.hs	2010-02-12 16:04:15.000000000 -0200
+++ c2hs-0.16.0/src/C2HS/C/Info.hs	2010-02-12 16:04:38.000000000 -0200
@@ -114,7 +114,7 @@
 size CULLongPT       = Storable.sizeOf (undefined :: CLLong)
 size CFloatPT        = Storable.sizeOf (undefined :: CFloat)
 size CDoublePT       = Storable.sizeOf (undefined :: CDouble)
-size CLDoublePT      = Storable.sizeOf (undefined :: CLDouble)
+--size CLDoublePT      = Storable.sizeOf (undefined :: CLDouble)
 size (CSFieldPT bs)  = -bs
 size (CUFieldPT bs)  = -bs
 
@@ -139,7 +139,7 @@
 alignment CULLongPT       = return $ Storable.alignment (undefined :: CULLong)
 alignment CFloatPT        = return $ Storable.alignment (undefined :: CFloat)
 alignment CDoublePT       = return $ Storable.alignment (undefined :: CDouble)
-alignment CLDoublePT      = return $ Storable.alignment (undefined :: CLDouble)
+--alignment CLDoublePT      = return $ Storable.alignment (undefined :: CLDouble)
 alignment (CSFieldPT bs)  = fieldAlignment bs
 alignment (CUFieldPT bs)  = fieldAlignment bs
 
Index: c2hs-0.16.0/src/C2HS/Gen/Bind.hs
===================================================================
--- c2hs-0.16.0.orig/src/C2HS/Gen/Bind.hs	2010-02-12 16:05:16.000000000 -0200
+++ c2hs-0.16.0/src/C2HS/Gen/Bind.hs	2010-02-12 16:06:40.000000000 -0200
@@ -793,10 +793,12 @@
 --
 foreignImport :: String -> String -> String -> Bool -> ExtType -> String
 foreignImport header ident hsIdent isUnsafe ty  =
-  "foreign import ccall " ++ safety ++ " " ++ show (header ++ " " ++ ident) ++
+  "foreign import ccall " ++ safety ++ " " ++ show entity ++
   "\n  " ++ hsIdent ++ " :: " ++ showExtType ty ++ "\n"
   where
     safety = if isUnsafe then "unsafe" else "safe"
+    entity | null header = ident
+           | otherwise   = header ++ " " ++ ident
 
 -- | Haskell code for the foreign import dynamic declaration needed by a call hook
 --
Index: c2hs-0.16.0/src/System/CIO.hs
===================================================================
--- c2hs-0.16.0.orig/src/System/CIO.hs	2010-02-12 15:58:34.000000000 -0200
+++ c2hs-0.16.0/src/System/CIO.hs	2010-02-12 16:03:27.000000000 -0200
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+{-# OPTIONS_GHC -cpp #-}
 --  Compiler Toolkit: Compiler I/O
 --
 --  Author : Manuel M T Chakravarty
@@ -63,7 +63,7 @@
             )
 where
 
-import Prelude (Bool, Char, String, FilePath, (.), Show)
+import Prelude (Bool, Char, String, FilePath, (.), ($), Show, return)
 import qualified System.IO as IO
 import qualified System.Directory   as IO (doesFileExist, removeFile)
 import qualified System.Environment as IO (getArgs, getProgName)
@@ -75,7 +77,12 @@
 -- -------------
 
 openFile     :: FilePath -> IO.IOMode -> PreCST e s IO.Handle
-openFile p m  = liftIO (IO.openFile p m)
+openFile p m  = liftIO $ do
+  hnd <- IO.openFile p m
+#if __GLASGOW_HASKELL__ >= 612
+  IO.hSetEncoding hnd IO.latin1
+#endif
+  return hnd
 
 hClose   :: IO.Handle -> PreCST e s ()
 hClose h  = liftIO (IO.hClose h)
@@ -99,10 +106,15 @@
 hPutStrLn h s  = liftIO (IO.hPutStrLn h s)
 
 writeFile                   :: FilePath -> String -> PreCST e s ()
-writeFile fname contents  = liftIO (IO.writeFile fname contents)
+writeFile fname contents  = do
+  hnd <- openFile fname IO.WriteMode
+  hPutStr hnd contents
+  hClose hnd
 
 readFile       :: FilePath -> PreCST e s String
-readFile fname  = liftIO (IO.readFile fname)
+readFile fname  = do
+  hnd <- openFile fname IO.ReadMode
+  liftIO (IO.hGetContents hnd)
 
 print   :: Show a => a -> PreCST e s ()
 print a  = liftIO (IO.print a)
