Opened 14 years ago

Closed 14 years ago

Last modified 48 years ago

#193 closed bug (Wont Fix)

When compiled with -O2, we get extra warnings

Reported by: nobody Owned by: nobody
Priority: normal Milestone:
Component: Compiler (FFI) Version: 6.0.1
Keywords: Cc:
Operating System: Architecture:
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


This is happending on a WinXP installation:
[arf]~/tst>cat Main.hs
module Main where

import CString

foreign import ccall "readline"  gnuRL :: CString -> IO 

main = main
[arf]~/tst>ghc --version
The Glorious Glasgow Haskell Compilation System, 
version 6.0.1
[arf]~/tst>ghc -c -ffi Main.hs
[arf]~/tst>rm Main.o Main.hi
[arf]~/tst>ghc -O2 -c -ffi Main.hs
c:/DOCUME~1/lerkok/LOCALS~1/Temp/ghc2484.hc: In 
function `s1cV_entry':
warning: implicit declaration of function `readline'
warning: assignment makes pointer from integer without 
a cast

For some reason, compiling with -O2 produces these 
warnings that don't show up otherwise.

Change History (1)

comment:1 Changed 14 years ago by wthaller

Status: assignedclosed
Logged In: YES 

You need to specify a header file in the foreign import declaration, 
like this:
foreign import ccall "readline/readline.h readline" gnuRL :: CString 
-> IO CString
or on the command line, using the -# include option, or in an 
OPTIONS pragma.

The reason why these warnings are only reported with -O is that 
GHC uses it's own native code generator most of the time, which 
doesn't use the headers, but uses GCC when optimizing, which 
does use them.

Note: See TracTickets for help on using tickets.