Windows: Using hsc2hs in combination with inline-c generates the .c files with invalid paths
Repro steps:
- Install Stack on a Windows development machine.
- Create new simple project with
stack new inlinecbug simple. - Rename
src/Main.hstosrc/Main.hscin theinlinecbugproject directory. - Build project with
stack buildand run withstack exec inlinecbugto verify that hsc2hs works correctly. - Replace content of
src/Main.hscwith following:
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
import qualified Language.C.Inline as C
C.include "<math.h>"
main :: IO ()
main = do
x <- [C.exp| double{ cos(1) } |]
print x
- In
inlinecbug.cabaladdinline-cto thebuild-dependssection ofexecutable inlinecbug. - Add the line
c-sources: src/Main.cto theexecutable inlinecbugsection. - Rebuild with
stack build.
Build will fail with a linker error referring to a undefined reference to an inline_c_main... function. List the files in the root directory of the project and you'll see that inline-c has generated a file with the name srcMain.c: i.e. the backslashes in the Windows path have been removed.
Building under Linux generates the C output file with the correct, expected path of src/Main.c and the program will compile, link and run as expected.
Edited by rcook