On 2012-10-11 16:34, Andrej Mitrovic wrote:

I don't have access to the include directives at all. The way I do it
is to have a "toNativeType" function which translates C/C++ types to D
and at the same time resolves includes. If a type is located in
another module (all non-fundamental types have a fileID field in XML)
then I insert that module's name to the currently generating module's
imports. Once all the module's symbols are generated I generate the
import directives.

Actually I already do the same. But that's only for the C standard library and a couple of Posix headers, basically all files in core.stdc. But the problem is that I get the full path to the source file where the symbol is defined. How do I turn that in to an import declaration? Something relative to the include paths?

With symbols from the standard library and the Posix headers there's the problem with many of the symbols actually are not defined in the header the documentation says. Instead they're included using various macro conditions from other "private" headers.

Well if the library defines files which get converted to modules like
'std' you could easily conflict with Phobos. Some words I check are:
std core gc rt object Object string toString toHash mangleof. But
there's probably more, when something clashes I add it to the list.

You could easily get standard aliases (the ones from implicitly
imported object.d) hijacked, e.g. if there was a string typedef in a C
library:

alias const(char)* string;  // hijacks string alias from object.d

I actually started a new thread for this:

http://forum.dlang.org/thread/[email protected]

--
/Jacob Carlborg

Reply via email to