Hugs FFI : HugsAPIx in GreenCard.h and output .c files

Kakihara Norihiro YIU04646@nifty.com
Thu, 24 May 2001 02:29:04 +0900


-------------------------------------
Environments:
    [Platform]            Windows 98
    [Haskell Interpreter] Hugs98 (February 2001; Windows Installer)
    [C Compiler]          lcc-win32 (Version 3.1)
-------------------------------------
Trying to use FFI on Hugs98, I prepared two files;
`_test.c' and `test.hs'.
--------------------------------------
[_test.c]

    #include <windows.h>
    BOOL WINAPI LibMain(
            HINSTANCE   hDLL,
            DWORD       Reason,
            LPVOID      Reserved){
        return TRUE;
    }
    
    int __declspec(dllexport) incr(int a){
        return a + 1;
    }


[test.hs]
    module Test(incr) where
    
    foreign import "Test" "incr" incr :: Int -> Int
--------------------------------------
And I invoked Hugs such and got an output file `Test.c'.
    
    hugs +G Test.hs

Because the header file `GreenCard.h', I got from
Green Card 2.01, declared not HugsAPI3 but HugsAPI2,
I compiled two .c files into `Test.dll'
AFTER REPLACING `HugsAPI3' INTO `HugsAPI2'.
Then I load `Test.hs' again.

    hugs Test.hs

But I got such an error:

    Unable to load GreenCard primitives

Because of the difference of the versions of headers?
Provided that, where could I get the appropriate version
of the GreenCard header file?



Thank you for your reading...

                                         Yours respectfully,
                                                 Kakihara N.

                                  mailto:YIU04646@nifty.com