worker-wrapper/iface trouble
Sven Panne
Sven.Panne@informatik.uni-muenchen.de
Sun, 19 Nov 2000 22:31:17 +0100
HOpenGL's saga through GHC bugs still continues! :-)
Something strange (worker-wrapper related?) is going on in
before-ghci-branch with a ghc-4.09 built a week ago:
--------------------------------------------------
module Foo where
import Foreign
inParam :: Storable a => (Ptr a -> IO b) -> a -> IO b
inParam act x = do
buf <- malloc
poke buf x
val <- act buf
free buf
return val
--------------------------------------------------
module Bar where
import Foreign
import Foo
marshallBool :: Bool -> Int
marshallBool False = 1234
marshallBool True = 5678
lightModel :: Either Int Bool -> IO ()
lightModel (Left i) = inParam (glLightModelfv 1111) i
lightModel (Right b) = glLightModeli 3333 (marshallBool b)
foreign import glLightModeli :: Int -> Int -> IO ()
foreign import glLightModelfv :: Int -> Ptr Int -> IO ()
--------------------------------------------------
module Baz(module Bar) where
import Bar
--------------------------------------------------
(ignore the "implicit declaration" warnings, could be fixed by -#include <GL/gl.h>)
--------------------------------------------------
jeanluc:/usr/src/packages/BUILD/fptools/hslibs/OpenGL/GL # ghc -O -fglasgow-exts -c Foo.hs
jeanluc:/usr/src/packages/BUILD/fptools/hslibs/OpenGL/GL # ghc -O -fglasgow-exts -c Bar.hs
ifaceBinds: free vars: zdwzdj_s3lZ
In file included from /tmp/ghc5262.c:4:
/tmp/ghc5262.hc: In function `Bar_zdwlvl_fast2':
/tmp/ghc5262.hc:50: warning: implicit declaration of function `glLightModelfv'
/tmp/ghc5262.hc: In function `Bar_zdwccall1_fast3':
/tmp/ghc5262.hc:287: warning: implicit declaration of function `glLightModeli'
jeanluc:/usr/src/packages/BUILD/fptools/hslibs/OpenGL/GL # ghc -O -fglasgow-exts -c Baz.hs
Baz.hs:1:
Failed to find interface decl for `Bar.$w$j'
from module `Bar'
Compilation had errors
--------------------------------------------------
Apart from a fix for this, I'd appreciate a few lines explaining the
worker-wrapper stuff in GHC or a pointer to a paper etc. I'd like to
fix bugs like that myself, if I only knew how... :-}
Cheers,
Sven