www.digitalmars.com         C & C++   DMDScript  

D - ..\ztc\cgobj.c 3034

reply "Dario" <supdar yahoo.com> writes:
Oops! Can't I compile this:
________________________________
// file main.d
import blah;

int main()
{
    blah.init();
    printf("it is %i", it[0]);
    return 0;
}
_________________________________
// file blah.d
module blah;

void init()
{
    it[0] = 32;
}

int[1] it;
_________________________________
This causes an internal error.

Moreover, if I write 'blah.it[0]' in function main() the compiler answers
'undefined identifier import blah.it'
If it were not an array, the problem wouldn't disappear.

Anyway, I'm wondering if that's legal. It should, shouldn't it?

I wrote a similar code in a program of mine (a module with an array
declaration, and another one which accesses that array). But when I compile
those sources the compiler doesn't emit any error, and the resulting
executable crashes (it outputs 'Error: ' and then crashes). Strange!
Aug 02 2002
parent reply "Walter" <walter digitalmars.com> writes:
As a workaround, compile the modules independently, and then link the .obj's
together. It is legal code and should work.
Aug 02 2002
parent reply "Dario" <supdar yahoo.com> writes:



together. It is legal code and should work. Walter



Does it make any conflict?
Aug 03 2002
parent "Walter" <walter digitalmars.com> writes:
"Dario" <supdar yahoo.com> wrote in message
news:aih7mj$1cg$1 digitaldaemon.com...




 together. It is legal code and should work. Walter




Does it make any conflict?

It's a compiler bug. I have it fixed, and will fold it into the next update. -Walter
Aug 03 2002