about header file parsing

akrl akrl@sdf.org
Tue Jan 1 00:00:00 GMT 2019


Marc Nieper-Wißkirchen <marc.nieper@gmail.com> writes:

> How would you handle, for example, gmp's header file?
> https://gmplib.org/repo/gmp/file/default/gmp-h.in
>
> Almost all of the public API is behind #define's. So even if the
> gcc_jit_context is filled with the functions that are declared in the
> header, one still needs to know the ABI of GMP to know which functions
> to call.
>
> In order to make it work in the general case (if this is at all
> possible), I think one has to turn the C frontend of GCC into a
> library (like libgccjit has turned the GCC middle/backend into a
> library). This hypothetical library X has its own context K that is
> populated by expanding and parsing the relevant header files.
>
> In this context K, we can then ask for expansion of strings of C
> tokens (e.g. in expression or statement context). Library X then
> returns the expansion in term of, say, a C-specific GENERIC tree,
> which can then be converted into/wrapped into a gcc_jit_object.
>
> -- Marc

So if I undertand correctly: the problem you are raising about defines is
 about naming in the sense that to use an API under defines you'll
need to use the the preprocessed expanded names in libgccjit?

If this is the case I still think the tool would be useful.

Andrea

-- 
akrl@sdf.org



More information about the Jit mailing list