[cfe-dev] Translate C includes to Java-like imports

Sebastian Redl sebastian.redl at getdesigned.at
Sat Oct 9 10:33:26 PDT 2010


On 09.10.2010, at 11:26, Jacob Carlborg wrote:

> I'm working on source to source translator which translates 
> Objective-C/C header files to D files. I've encountered a problem and 
> that is how the include system works in the two languages. The import 
> system in D works more like it does in Java than in C. For example:
> 
> If I have three files:
> 
> * A.h, includes B.h
> * B.h, includes C.h
> * C.h
> 
> In C (the language) A.h would have access to everything in B.h and C.h 
> as well. In D this is not the case, I would have to explicitly import 
> both B.h and C.h to access it from A.h. So I guess the question is: for 
> a given type, typedef or similar how can I determine where it's declared 
> and if the file that it's declared in are already included or not?

You might want to get in touch with Craig Silverstein from Google. He's using Clang to implement "Include-What-You-Use" (he'll give a talk at the LLVM dev meeting), which I think faces very similar problems.

Sebastian



More information about the cfe-dev mailing list