www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Multi-file project problem with Visual D

reply "Mike" <kdx7214 gmail.com> writes:
I've created a small Windows based program using a win32 library 
I found online.   That part is working just fine.

I've also created a second file (called util.d) and within it 
defined a class called MyData (with a member function called 
Read()).

Within my main program I instantiate and try to call the Read() 
method.  No errors are generated but nothing gets called.   Right 
now the Read() method just does a throw so I know something is 
going on.

What am I missing here?   I would think the compiler would 
generate an error if something was missing.

winmain.d:
---------------------------------
extern(Windows)
LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM 
lParam)
{

     switch (message)
     {
         case WM_CREATE:
	    f.Read() ;
             return 0 ;

  /* ... */

} // WndProc



util.d:
----------------------------------

class MyData {
public:
     void Read() {
         throw new Exception("No!", __FILE__, __LINE__) ;
     } // void Read()
} // class Data
Jun 01 2014
parent "Mike" <kdx7214 gmail.com> writes:
On Monday, 2 June 2014 at 01:01:22 UTC, Mike wrote:
 I've created a small Windows based program using a win32 
 library I found online.   That part is working just fine.

 I've also created a second file (called util.d) and within it 
 defined a class called MyData (with a member function called 
 Read()).

 Within my main program I instantiate and try to call the Read() 
 method.  No errors are generated but nothing gets called.   
 Right now the Read() method just does a throw so I know 
 something is going on.

 What am I missing here?   I would think the compiler would 
 generate an error if something was missing.

 winmain.d:
 ---------------------------------
 extern(Windows)
 LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM 
 lParam)
 {

     switch (message)
     {
         case WM_CREATE:
 	    f.Read() ;
             return 0 ;

  /* ... */

 } // WndProc



 util.d:
 ----------------------------------

 class MyData {
 public:
     void Read() {
         throw new Exception("No!", __FILE__, __LINE__) ;
     } // void Read()
 } // class Data
Doing more testing and debugging found that the value of the instance is 0, which leads me to believe something is happening with the instantiation. Back to the books I suppose.
Jun 01 2014