any tool to at least partially convert C++ to D (htod for source
Michel Fortin
michel.fortin at michelf.com
Fri Mar 12 06:19:42 PST 2010
On 2010-03-11 21:35:42 -0500, Walter Bright <newshound1 at digitalmars.com> said:
> Michel Fortin wrote:
>> Ah, you're right indeed. I thought it was std.stdiobase that imported
>> std.stdio, but its the reverse so it's a little better.
>>
>> Still, std.stdiobase uses this clever external definition to avoid a
>> circular import:
>>
>> extern(C) void std_stdio_static_this();
>>
>> This hack is basically just a bypass of the circular dependency check
>> for one module. If more than one module use it, you're at risk of
>> having the behaviour dependent on the link order.
>
> No, the transitive nature of the dependency checking insures it is NOT
> dependent on link order.
What I meant is that this is dependent on link order (and I tested it):
module a;
import a_base;
import b;
int ai;
extern(C) void initA() { ai = bi+2; }
module a_base;
extern(C) void initA();
static this() { initA(); }
module b;
import b_base;
import a;
int bi;
extern(C) void initB() { bi = ai+4; }
module b_base;
extern(C) void initB();
static this() { initB(); }
module main;
import b;
import a;
import std.stdio;
void main() {
writeln("a.ai = ", ai, " b.bi = ", bi);
}
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list