Ticket #7630 (closed bug: fixed)

Opened 4 months ago

Last modified 4 months ago

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

  Changed 4 months ago by simonmar

  • status changed from new to closed
  • difficulty set to Unknown
  • resolution set to invalid

You need to add CAPI to your LANGUAGE pragma.

follow-up: ↓ 4   Changed 4 months ago by guest

  • status changed from closed to new
  • failure changed from None/Unknown to GHC rejects valid program
  • resolution invalid deleted

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

  Changed 4 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.

in reply to: ↑ 2   Changed 4 months ago by thoughtpolice

  • status changed from new to closed
  • resolution set to fixed

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.