I'm trying to build a Haskell executable with an FFI against some C++ sources.
I have a C header (cstuff/foo.h) like this:
#ifndef _FOO_H_
#define _FOO_H_
#include <somecppheader.c> // Some header outside of my control with C++ constructs
void foo();
#endif
The implementation of foo shouldn't matter. It does something and uses something declared in somecppheader.h along the way.
The executable section in the Cabal file looks like this:
executable botprog
main-is: Main.hsc
other-extensions: ForeignFunctionInterface
build-depends: base >=4.7 && <4.8
build-tools: hsc2hs
default-language: Haskell2010
include-dirs: cstuff
c-sources: cstuff/foo.cpp
pkgconfig-depends: somelib -- The one that contains somecppheader.h
Main.hsc looks something like this:
{-# LANGUAGE ForeignFunctionInterface #-}
#include <foo.h>
foreign import ccall "foo.h foo" :: IO ()
main = foo >> putStrLn "Called foo."
hsc2hs isn't actually needed in this example, it's just used to, to trigger the error i'm trying to describe.
The problem is that somecppheader.h is a C++ header with C++ specific constructs and the include of foo.h seems to compile it as a C header, which fails, because of C++ constructs, like class definitions.
How can I tell hsc2hs or Cabal that foo.h needs to be compiled with g++, rather than gcc?