www.digitalmars.com         C & C++   DMDScript  

D - DMD 0.79 bug: Externs not working.

reply Burton Radons <loth users.sourceforge.net> writes:
This requires three files.  Here is "impl.d":

     module stub;

     class Class
     {
         this () { Method (); }
         void Method () { printf ("Hello, world!\n"); }
     }

Here is "stub.d":

     module stub;

     class Class
     {
         this ();
         void Method ();
     }

So "impl.d" contains the implementation while "stub.d" contains just the 
stub.  Here is "user.d":

     import stub;

     class Inheritor : Class
     {
         this ()
         {
             super ();
         }
     }

     void main ()
     {
         new Inheritor;
     }

The compilation process is like this:

     dmd -c impl.d
     dmd impl.obj stub.d user.d test.exe
     test.exe

This causes an Access Violation right inside the Method call.  It should 
and has historically worked.  I don't know what version it was 
introduced into DMD, likely in the 0.7* series.
Jan 26 2004
next sibling parent reply "Walter" <walter digitalmars.com> writes:
Does it work if they are all compiled with separate dmd commands?
Jan 27 2004
parent Burton Radons <loth users.sourceforge.net> writes:
Walter wrote:

 Does it work if they are all compiled with separate dmd commands?
After the amendment, no (I don't think it would link with the first version of the commands). It looks like incorrect sub-classing is what's generating the problem as I can instantiate a Class from "user.d" directly without a problem (by adding "new Class;" to the beginning of "main()"); it's only once I try my own sub-class that it fails.
Jan 27 2004
prev sibling parent Burton Radons <loth users.sourceforge.net> writes:
Burton Radons wrote:

 This requires three files.  Here is "impl.d":
 
     module stub;
 
     class Class
     {
         this () { Method (); }
         void Method () { printf ("Hello, world!\n"); }
     }
 
 Here is "stub.d":
 
     module stub;
 
     class Class
     {
         this ();
         void Method ();
     }
 
 So "impl.d" contains the implementation while "stub.d" contains just the 
 stub.  Here is "user.d":
 
     import stub;
 
     class Inheritor : Class
     {
         this ()
         {
             super ();
         }
     }
 
     void main ()
     {
         new Inheritor;
     }
 
 The compilation process is like this:
 
     dmd -c impl.d
     dmd impl.obj stub.d user.d test.exe
     test.exe
This process isn't quite right. They should be: dmd -c impl.d dmd impl.obj user.d test.exe test.exe "stub.d" was removed from the second line.
Jan 27 2004