The Cabal file of the Win32
package has a c-sources
which includes cbits/errors.c
which provides a C function getErrorMessage
; Win32
uses it to create a Haskell function with the same name.
I created a package which copied that C function (verbatim). However, when I compiled a second package that depended on both Win32
and my new package, the GHC runtime linker complained about a fatal error: it found a duplicate definition for symbol getErrorMessage
while processing an object file for my new package and said it was previously defined in an object file for the Win32
package. (This resulted in a āpanic! (the āimpossibleā happened)ā and a suggestion it be reported as a GHC bug.)
My question is this: why does the C function result in a symbol in the GHC object file for the package? I had assumed - probably wrongly - that the C function would be somehow āinternalā to the package. Is it possible to specify that the C function is only āinternalā? If not, does that mean that C functions used in c-sources
need to be named in a way that makes name clashes unlikely?