On Tue, Jul 16, 2013 at 8:05 AM, Dicebot <span dir="ltr"><<a href="mailto:public@dicebot.lv" target="_blank">public@dicebot.lv</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Tuesday, 16 July 2013 at 14:15:55 UTC, Jacob Carlborg wrote:<br>
</div><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Made a proof of concept to automatically parse, translate and import C header files in D using DStep. DMD is linked against DStep and does not start new process to make the translation.<br>
</blockquote>
<br></div>
While this a relatively common request, I don't think such stuff belongs to compiler. It creates extra mandatory dependencies while providing little advantage over doing this as part of a build system.<br>
<br>
So far I am perfectly satisfied with invoking dstep from a Makefile.<br>
</blockquote></div><div><br></div><div>I agree that this stuff doesn't belong to compiler, however Makefiles suck (not even portable) and build systems should be avoided whenever a more integrated solution exist. </div>
<div><br></div><div>So how about a library solution instead, which doesn't require compiler change:</div><div><br></div><div>----</div><div>import parse_c_header_importer; </div><div>mixin(parse_c_header(import("foo.h")));</div>
<div><div>void main () { foo();}</div></div><div>----</div><div><div><br></div></div><div>There are several options:</div><div><br></div><div>A)</div><div><div>mixin(parse_c_header(import("foo.h"))); => defines D symbols for everything in foo.h (excluding things included by it)</div>
<div><br></div><div>B)</div><div></div><div>mixin(parse_c_header(import("foo.h"),recursive)); => same, but recursively (probably not very useful, but could be useful if we instead used .i swig interface files.</div>
<div><div><br></div><div>C)</div><div>The least wasteful:</div><div></div></div><div>void foo();</div><div>int bar();</div><div>mixin(parse_c_header(import("foo.h"),foo,bar));</div><div></div></div><div>=> only defines symbols provided</div>
<div><br></div><div>(I've proposed this syntax in an earlier thread)</div>