<div dir="ltr">Hi Nick,<div><br></div><div>As far as I can tell from a quick look at hsqml, the stuff in Setup.hs isn't related to C2HS.  What's more relevant is that hsqml defines a C library wrapper around the C++ library it uses -- C2HS is only used on that C wrapper, not on the C++ library itself.  In general, C2HS doesn't support C++ at all, because it needs to be able to parse the header files that it includes and we use the C parser from the languagge-c package to do that.  Any C++ constructs will just cause breakage.  And your "old school" FFI definition doesn't look in any header files, which is why it has no trouble.</div>
<div><br></div><div>Basically, if you want to do something like what hsqml does, just take a look in the cbits directory there, in particular at hsqml.h which is the header that defines the C wrapper around the C++ library.  This hsqml.h header is the one that's included in the C2HS files.  If you want to wrap a C++ library directly, C2HS probably isn't the tool for the job.  I know there was some work during the last GSOC on a C++ FFI wrapper, but I don't know if anything concrete came of it.</div>
<div><br></div><div>Cheers,</div><div><br></div><div>Ian.</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 6 April 2014 20:22, Nick Rudnick <span dir="ltr"><<a href="mailto:nick.rudnick@gmail.com" target="_blank">nick.rudnick@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear all,<div><br></div><div>maybe this is a piece of c2hs behaviour I missed to understand, but it appears happening with C++ style includes deep in the header call hierarchy – in case of a such backend C++ library, if one wishes to refer to by *.h's in c2hs (e.g. for access to types of it), one might have a problem.</div>

<div><br></div><div>- 8< cSample.h ---------------------------------------------</div><div>#include <iostream> ///////// here, with c2hs, leading to build abort<br></div><div>#ifdef __cplusplus<br></div><div>extern "C" {</div>

<div>#endif</div><div>void sampleFunction();</div><div>#ifdef __cplusplus</div><div>}</div><div>#endif</div>- 8< cSample.cpp ---------------------------------------------<div><div>#include "cSample.h" </div>
<div>
#include <iostream> ///////// here no problem</div><div><br></div><div>void sampleFunction(){ </div><div>  std::cout << "OK" << std::endl;</div><div>}</div>- 8< ----------------------------------------------------------------<div>

<br></div><div>While 'old school' FFI (foreign import ccall) handles this effortlessly, c2hs uses to abort with an exception like </div><div><div>C/cSample.h:3:20: fatal error: iostream: No such file or directory</div>

<div>compilation terminated.</div></div><div><br></div><div>I see that hsqml gets around this, but apparently by tweaking Setup.hs in a way not quite trivial – would this be necessary in any case, or are there simpler alternatives?</div>

<div><br></div><div>Please excuse if I oversaw something, but I am afraid I didn't see this interesting issue covered elsewhere.</div><div><br></div><div>Thank you a lot in advance & cheers, Nick</div><div><br></div>

<div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div></div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Ian Ross   Tel: +43(0)6804451378   <a href="mailto:ian@skybluetrades.net" target="_blank">ian@skybluetrades.net</a>   <a href="http://www.skybluetrades.net" target="_blank">www.skybluetrades.net</a>
</div>