Translate C includes to Java-like imports

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?

Forgot to send to the list…

I guess I could but I would rather 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

He has a project hosted here: Google Code Archive - Long-term storage for Google Code Project Hosting.

Thanks for the link.