#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 Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

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 15 months ago by simonmar

  • Difficulty set to Unknown
  • Resolution set to invalid
  • Status changed from new to closed

You need to add CAPI to your LANGUAGE pragma.

comment:2 follow-up: Changed 15 months ago by guest

  • Resolution invalid deleted
  • Status changed from closed to new
  • Type of failure changed from None/Unknown to GHC 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 15 months 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 15 months ago by thoughtpolice

  • Resolution set to fixed
  • Status changed from new to closed

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.