Summary: DMD compiles incorrect code on windows
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from 2010-12-09 08:50:08 PST ---
Created an attachment (id=845)
Compiling and running in windows command prompt

Code that should not compile, imported from C, compiles on windows, but does
NOT compile on Linux.

Here the example:
// cfile.c file
extern int globalFromD;

void functionFromC(int a) {
   globalFromD = a;
// end cfile.c

// dfile.d
extern(C) { // this is needed to make it available from C
        int globalFromD;
extern(C) { // also needed when listing the prototypes for your C functions
        void functionFromC(int);

import std.stdio; // for writefln

int main() {
        globalFromD = 100;
        writefln("%d", globalFromD);

        writefln("%d", globalFromD);

        return 0;
// end dfile.d

I compile with:
dmc -c cfile.c
And I get  an cfile.obj, which is the object code (.o in gcc).
Then I compile the D code
dmd dfile.d cfile.obj
and I get no errors, so I run it, the result:
// start result

// end result 

I've posted this on the newsgroup( d.D.learn, Subject:"Calling C functions" )
and apparently it's some kind of bug.

More info:

dmc version: 8.42n
dmd version: 2.050

Windows version: Windows XP.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to