Search code examples
haskellffihaskell-stack

How do I pass C compiler flags in a Haskell Stack package.yaml


I'm working on a Haskell project involving some FFI, and I keep making small typos in the names of C functions in my Haskell code, which due to implicit function declaration, results in a warning, but not an error.

I'd like to pass -Werror-implicit-function-declaration to the gcc arguments, in order to turn these warnings into errors.

I'm using Haskell Stack, and it's not obvious to me what I ought to add to my package.yaml in order to do this? What field should I add?


Solution

  • Looking at some of my local projects, here's one example:

    library:
        exposed-modules:
        - ...
        source-dirs:
        - ...
        ghc-options:
        - ...
        pkg-config-dependencies:
        - glib-2.0
        extra-lib-dirs:
        - /Workspace/INSTALL/lib
        include-dirs:
        - ./native
        - /Workspace/INSTALL
        c-sources:
        - ./native/*.c
        cc-options:
        - -O3 -fPIC -g3 -Wall -pedantic -Wno-variadic-macros -Werror
    

    You can find the full reference documentation at https://github.com/sol/hpack.