addCStub doesn't allow control over compiler flags or source file file
Currently if you pass a C source file on the GHC command line you can control whether the compiler treats it as C or C++ via the it's extension: GCC will treat a file ending in
.c as C, whereas
.cpp is treated as C++.
However, we currently have no means of controlling what language a stub added with in Template Haskell with
addCStub will be treated as. Consequently it is currently impossible to compile a C++ source file with
addCStub without using
-optc. Moreover, you can't have mixed C/C++ stubs at all.
It really seems like this interface should be amended to fix this before we release it in 8.2. Perhaps
addCStub should accept both the source and a set of compiler flags which will be added to the usual flags (allowing one to pass
-x c++ to the compiler when compiling C++ files)?