[cfe-dev] clang headers - can they be included from a memory location?

Douglas Gregor dgregor at apple.com
Mon Oct 18 07:14:14 PDT 2010


On Oct 17, 2010, at 1:12 PM, Graham Wakefield wrote:

> It's great that an embedded clang can compile source files supplied as string buffers (rather than files). We wondered if there any way to coerce clang to do something similar for headers? That is, to resolve #include <xxx.h> to use a pre-loaded string buffer of the contents of xxx.h, instead of the file itself? This would make our embedded system much easier to distribute...
> 
> I tried using CompilerInstance.getPreprocessorOpts().addRemappedFile(name, buffer), but it doesn't appear that the header search resolves it.  

Are you giving it a full path name, and is that path in the search paths? This should work, IIRC.

> Would a PCH help?

PCH could be an optimization; it generally doesn't change behavior.

	- Doug



More information about the cfe-dev mailing list