Opened 4 years ago

Closed 4 years ago

#7630 closed bug (fixed)

FFI: "capi" calling convention doesn't work

Reported by: guest Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.6.1
Keywords: Cc:
Operating System: Linux Architecture: x86
Type of failure: GHC rejects valid program Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

According to http://www.haskell.org/ghc/docs/7.6.1/html/users_guide/ffi.html#ffi-capi there is a capi calling convention, but ghc disagrees:

% cat capi.hs 
{-# LANGUAGE ForeignFunctionInterface #-}

import Foreign.C

foreign import capi "math.h value M_PI" mPI :: CDouble

main :: IO ()
main = print mPI

% ghc capi.hs
[1 of 1] Compiling Main             ( capi.hs, capi.o )

capi.hs:5:16: parse error on input `capi'

Is the documentation wrong?

Change History (4)

comment:1 Changed 4 years ago by simonmar

difficulty: Unknown
Resolution: invalid
Status: newclosed

You need to add CAPI to your LANGUAGE pragma.

comment:2 Changed 4 years ago by guest

Resolution: invalid
Status: closednew
Type of failure: None/UnknownGHC rejects valid program

I did but ghc doesn't accept it:

% cat capi.hs
{-# LANGUAGE ForeignFunctionInterface, CAPI #-}

import Foreign.C

foreign import capi "math.h value M_PI" mPI :: CDouble

main :: IO ()
main = print mPI

% ghc capi.hs

capi.hs:1:40: Unsupported extension: CAPI

comment:3 Changed 4 years ago by thoughtpolice

The docs are wrong. The extension is actually called CApiFFI, and your example works if you use that instead of CAPI.

This should be fixed in the users manual and merged into 7.6.2 I think. I'll fix it in HEAD with this bug as the ticket.

comment:4 in reply to:  2 Changed 4 years ago by thoughtpolice

Resolution: fixed
Status: newclosed

Nevermind; this was already fixed a while back:

Author: shelarcy <shelarcy@gmail.com>
Date:   Tue Oct 2 17:10:13 2012 +0900

    Fix typo in the documentation of CApiFFI
    
    Signed-off-by: Gabor Greif <ggreif@gmail.com>
Note: See TracTickets for help on using tickets.