[cfe-users] How to handle C standard library includes?

Joel Andersson via cfe-users cfe-users at lists.llvm.org
Wed Sep 16 04:37:31 PDT 2015


Hi,

I'm trying to add just-in-time compilation support to our library using
Clang via the C++ API. Basically we generate C code and compile and and
execute this code using Clang + LLVM JIT.

We've been struggling how to correctly handle includes to C standard
library, e.g. "math.h" or "stdio.h". If no paths are set, we get errors of
the form:

foo.c:3:10: fatal error: 'math.h' file not found
#include <math.h>

Until now we've solved this by locating a math.h and stdio.h on the system.
But this is not portable and I feel that there must be a better way. I read
about "modules" in clang, and got the impression that headers like these
should be available in binary form inside the clang binaries, but if this
is the case, I'm not sure how to enable it.

I'm using llvm/clang from Homebrew, version 3.6.2.

Best regards,
Joel


-- 
-- 
Joel Andersson, PhD
Ptge. Busquets 11-13, atico 3
E-08940 Cornella de Llobregat (Barcelona), Spain
Home: +34-93-6034011
Mobile: +34-63-4408800 (in Sweden also +46-707-360512)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20150916/be68a5e9/attachment.html>


More information about the cfe-users mailing list