[cfe-dev] Generate a header file from a source file with clang

Philip Reames listmail at philipreames.com
Fri Mar 21 11:04:21 PDT 2014


I hacked together a tool which did this a while back.  If you don't care 
about is handling the full power of C++, it's not that difficult.

Basically, run it through the parser, then perform walks over the AST.

Note: This assumes that the original code compiles cleanly _without_ 
including your newly generated header.

Note: I didn't use the 'plugin' mechanism.  So no comment on that part 
of the question.

Philip

On 03/21/2014 10:17 AM, Vassil Vassilev wrote:
> Hi,
>   Maybe a silly question but I'd like your opinion on it:
>   How difficult would be (if possible) to implement a clang plugin 
> which can generate a header file from a source file with 
> implementation. The idea is to ask clang to build a library from a 
> 'single' source file to generate a header file for it.
> Many thanks,
> Vassil
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list