0

I work on code I have not written. It uses the Haskell Foreign Function Interface (FFI) and includes some code in C.

The 9.0.1 GHC documentation gives an example of such includes as:

#include <stdio.h>
#include "HsFFI.h"

and I do not see an indication what difference is between using <..> and "..". Is there any?

I have difficulties when uploading the code to hackage, it complains about a file where the include is written as

fatal error: qhull_ra.h: No such file or directory
     #include "qhull_ra.h"

The file exists and it is found if I compile locally with stack build (but sometimes I see the same error message - not understanding when).

jpmarinier
  • 4,427
  • 1
  • 10
  • 23
user855443
  • 2,596
  • 3
  • 25
  • 37
  • 3
    It is a very common C feature. See for example [earlier SO question](https://stackoverflow.com/questions/21593/what-is-the-difference-between-include-filename-and-include-filename) - note the low number of the question. Essentially, the double quotes are for the local include files of your project. Angle brackets are for system include files such as `stdio.h`, and include files located in directories mentioned in the `-I` argument passed to the C compiler. – jpmarinier Jul 26 '22 at 09:25
  • @jpmarinier: I do not see why I did not see this old question, which explains partially what I need to know. – user855443 Jul 27 '22 at 15:24
  • How does this apply to GHC (and especially cabal - hackage). I have in the cabal file`include-dirs: ` and `C-sources:`. I have troubles with a file in `C-sources` and found it works more reliable when inlcuded in `<..>` than when it is in `".."`. The hackage build checker, for example, does not find it in `".."`. – user855443 Jul 27 '22 at 15:27
  • I think you might want to ask a new cabal-specific question for this. As is, the title is telling that this is an elementary (and duplicate) question on C/C++ programming. Some of the people monitoring the haskell tag are proper cabal experts (much better at it than me at least). Best to use the *cabal* tag, and include a small self-contained example of the problem at hand. As Haskell obviously does not have its own cpp preprocessor, the crux of the problem is how the Cabal configuration variables get translated into command line arguments for the OS-provided cpp command. – jpmarinier Jul 28 '22 at 14:27
  • Thank you very much for the advice. I will follow up (in a few days)! – user855443 Jul 28 '22 at 16:24

0 Answers0