problems with FFI including h files

Simon Marlow simonmar@microsoft.com
Mon, 3 Jun 2002 12:46:19 +0100


> Sad, but very true! And GHC's headers are not very nice in=20
> this respect:
>=20
>     panne@jeanluc:~> grep '#define [^ \t][^ \t] '=20
> /usr/lib/ghc-5.03/include/*
>     /usr/lib/ghc-5.03/include/PrimOps.h:#define C 0
>     /usr/lib/ghc-5.03/include/PrimOps.h:#define R 1
>     /usr/lib/ghc-5.03/include/PrimOps.h:#define C 1
>     /usr/lib/ghc-5.03/include/PrimOps.h:#define R 0

Yikes!  Fixed, thanks.

>     panne@jeanluc:~> grep '#define [^ \t][^ \t] '=20
> /usr/lib/ghc-5.03/include/*
>     /usr/lib/ghc-5.03/include/Regs.h:#define R1 (BaseReg->rR1)
>     /usr/lib/ghc-5.03/include/Regs.h:#define R2 (BaseReg->rR2)
>     /usr/lib/ghc-5.03/include/Regs.h:#define F1 (BaseReg->rF1)
>     /usr/lib/ghc-5.03/include/Regs.h:#define F2 (BaseReg->rF2)
>     /usr/lib/ghc-5.03/include/Regs.h:#define F3 (BaseReg->rF3)
>     /usr/lib/ghc-5.03/include/Regs.h:#define F4 (BaseReg->rF4)
>     /usr/lib/ghc-5.03/include/Regs.h:#define D1 (BaseReg->rD1)
>     /usr/lib/ghc-5.03/include/Regs.h:#define D2 (BaseReg->rD2)
>     /usr/lib/ghc-5.03/include/Regs.h:#define L1 (BaseReg->rL1)
>     /usr/lib/ghc-5.03/include/Regs.h:#define Sp (BaseReg->rSp)
>     /usr/lib/ghc-5.03/include/Regs.h:#define Su (BaseReg->rSu)
>     /usr/lib/ghc-5.03/include/Regs.h:#define Hp (BaseReg->rHp)
>=20
> And so on...
>=20
> SimonM: What about a "poor man's" namespace, i.e. prefixing=20
> every macro,
> type, etc. with "GHC"/"ghc"? OpenGL, GLUT, GTK, etc. do a=20
> similar thing,
> and although it's a primitive measure, it's very effective.

We really *should* do this, I know.  The problem is that it isn't free
by a long shot: it'll make .hc files significantly larger, and obfuscate
a lot of code. =20

Anyone have any ideas that don't have such a big impact?

Cheers,
	Simon