Skip to content

Unexpected behaviour of import ccall "header.h function"

When I write

foreign import ccall "myheader.h myfunction" function :: IO ...

Is GHC supposed to check the existence of the header file, or do anything with it?

Because I can still write "myheaderBLA.h myfunction" and it doesn't care about the first word (no error, ever, not even in linking, executable builds all fine).


Relatedly, I can write

foreign import ccall "some.rubbish" f :: IO ...

and as long as "some.rubbish" contains a dot, nothin in the system will ever complain.

carter suggested that maybe names with a dot inside are ignored by a linker.

This leads me to the question: In my example above, is myheaderBLA.h actually understood as some kind of file and ignored by e.g. GHC, or is it a garbled symbol name? In that case, why does http://www.haskell.org/onlinereport/haskell2010/haskellch8.html suggest ccall "string.h strlen"? In the other case, why would it suggest this if the "string.h" part is ignored?

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