Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading