Skip to content

[PATCH] generated FFI ccall stub prototypes are incomplete

For generated C prototypes in which there are no arguments, the argument list should be "void", not blank. The GCC flag -Wstrict-prototypes warns about this.

To reproduce: create file Test.hs as follows

{-# OPTIONS -fffi #-} 

module Test where

foreign export ccall "foo" foo :: IO ()

foo = putStrLn "hello world"

and file use_test.c as follows:

#include "Test_stub.h"

Execute the following:

ghc -c Test.hs
gcc -Wstrict-prototypes -I/usr/lib/ghc-6.6/include -c use_test.c

(change path as appropriate). Expected output: nothing. Actual output:

In file included from use_test.c:1:
Test_stub.h:5: warning: function declaration isn’t a prototype

Patch attached.

Trac metadata
Trac field Value
Version 6.9
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (FFI)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Multiple
Architecture Multiple
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information