Hi,
I have a problem when processing "vte/vte.h" (from
vte-0.11.10) with c2hs-0.12.0 and glibc-2.3.3:
LANG=C c2hs --cppopts="-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/X11R6/include -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include" vte.h Vte.chs
c2hs: Generic fatal error.
/usr/include/sys/sysmacros.h:43: (column 1) [FATAL]
>>> Syntax error!
The symbol `{' does not fit here.
It seems sys/sysmacros.h changed from glibc-2.3.2. Here is
the context:
# if defined __GNUC__ && __GNUC__ >= 2
__extension__ extern __inline unsigned int
gnu_dev_major (unsigned long long int __dev) __THROW
{
return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff);
}
Jens
ps glibc-2.3.3 will be in Fedora Core 2, which is being released
on Tuesday.
pps I just uploaded c2hs-0.12.0 rpms built with glibc-2.3.3
to <http://haskell.org/~petersen/rpms/c2hs/>. I applied the
following patch to build it with ghc-6.2.1:
--- c2hs-0.12.0/c2hs/c/CAttrs.hs~ 2004-05-16 09:46:07.000000000 +0900
+++ c2hs-0.12.0/c2hs/c/CAttrs.hs 2004-05-16 09:46:07.000000000 +0900
@@ -144,7 +144,7 @@
--
leaveObjRangeC :: AttrC -> AttrC
leaveObjRangeC ac = ac {
- defObjsAC = fst . leaveRange . defObjsAC $ ac,
+ defObjsAC = fst . leaveRange . defObjsAC $ ac
}
-- add another definitions to the object name space (EXPORTED)
All,
So far as I know c2hs doesn't support hierarchical modules well. I've
not tried the latest version, so apologies if this has already been
addressed.
Under the Hierarchical Module Namespace Extension
http://www.haskell.org/hierarchical-modules/
module names can have dots '.' in them and when mapping these to
filenames they are converted to directory separators.
Foo.Bar.Baz -> Foo/Bar/Bas(.hs|.chi|etc)
I've knocked up a patch that I think solves the problem (works for me),
but an expert eye would be appreciated.
I've made a change in two places:
* CHSLexer.hs: identOrKW function, added '.' as an allowable
character in an identifier within binding hooks.
* CHS.hs: parseImport function, inserted a call to a new function
moduleNameToFileName before calling loadCHI. The new function
does the module name to file path conversion.
Here's a patch (it's against the gtk2hs fork of c2hs but it's quite
small so the idea should be clear)
diff -U2 -r1.2 CHSLexer.hs
--- CHSLexer.hs 1 Oct 2002 15:17:07 -0000 1.2
+++ CHSLexer.hs 16 Jul 2004 18:52:26 -0000
@@ -557,5 +557,5 @@
--
identOrKW =
- letter +> (letter >|< digit >|< char '\'')`star` epsilon
+ letter +> (letter >|< digit >|< char '\'' >|< char '.')`star` epsilon
`lexactionName` \cs pos name -> (idkwtok $!pos) cs name
where
diff -U2 -r1.4 CHS.hs
--- CHS.hs 20 May 2004 16:42:17 -0000 1.4
+++ CHS.hs 16 Jul 2004 18:52:26 -0000
@@ -747,9 +747,14 @@
CHSTokQualif _: CHSTokIdent _ ide:toks -> return (True , ide, toks)
_ -> syntaxError toks
- chi <- loadCHI . identToLexeme $ modid
+ chi <- loadCHI . moduleNameToFileName . identToLexeme $ modid
toks'' <- parseEndHook toks'
frags <- parseFrags toks''
return $ CHSHook (CHSImport qual modid chi pos) : frags
+moduleNameToFileName :: String -> FilePath
+moduleNameToFileName = map dotToSlash
+ where dotToSlash '.' = '/'
+ dotToSlash c = c
+
parseContext :: Position -> [CHSToken] -> CST s [CHSFrag]
parseContext pos toks = do
Does this seem ok? It makes me a bit nervous changing the lexical
definition of an identifier (we really only want to change the module
identifier definition, not all identifiers).
Duncan