Opened 11 years ago

Closed 11 years ago

Last modified 44 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: Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

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

import CString

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

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':
c:/DOCUME~1/lerkok/LOCALS~1/Temp/ghc2484.hc:52: 
warning: implicit declaration of function `readline'
c:/DOCUME~1/lerkok/LOCALS~1/Temp/ghc2484.hc:52: 
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 11 years ago by wthaller

  • Status changed from assigned to closed
Logged In: YES 
user_id=566359

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.