www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Bug 169] New: Compilation of module fails with -unittest

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=169

           Summary: Compilation of module fails with -unittest
           Product: D
           Version: 0.159
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: CppCoder gmail.com


module eventpool;

import std.c.windows.windows;

extern (Windows)
{
        HANDLE CreateEvent(
                LPSECURITY_ATTRIBUTES lpEventAttributes,
                BOOL bManualReset,
                BOOL bInitialState,
                LPCTSTR lpName
        );

        BOOL SetEvent(
                HANDLE hEvent
        );

        BOOL ResetEvent(
                HANDLE hEvent
        );
}

class Event
{
        public HANDLE event;

        public this( bool manualReset, bool initialState )
        {
                event = CreateEvent( null, manualReset, initialState, null );
        }

        public this()
        {
                this( true, false );
        }

        public ~this()
        {
                CloseHandle( event );
        }

        bool signalled()
        {
                ulong waitRes;
                waitRes = WaitForSingleObject( event, 0 );

                return (waitRes == WAIT_OBJECT_0);
        }

        void signalled( bool isSignalled )
        {
                if ( isSignalled )
                {
                        SetEvent( event );
                }
                else
                {
                        ResetEvent( event );
                }
        }

        unittest
        {
                Event ev = new Event();
                ev.signalled = true;
                assert( ev.signalled == true );
                ev.signalled = false;
                assert( ev.signalled == false );

                delete ev;
        }
}

when compiling with "-unittest":
eventpool.obj(eventpool)
 Error 42: Symbol Undefined _CreateEvent 16
--- errorlevel 1


-- 
May 30 2006
next sibling parent reply Don Clugston <dac nospam.com.au> writes:
There's no CreateEvent() function in Windows.
It's CreateEventW() or CreateEventA(), which then get aliased:

extern (Windows)
{
          HANDLE CreateEventW(
...
}
alias CreateEventW CreateEvent;



d-bugmail puremagic.com wrote:
 http://d.puremagic.com/bugzilla/show_bug.cgi?id=169
 
            Summary: Compilation of module fails with -unittest
            Product: D
            Version: 0.159
           Platform: PC
         OS/Version: Windows
             Status: NEW
           Severity: normal
           Priority: P2
          Component: DMD
         AssignedTo: bugzilla digitalmars.com
         ReportedBy: CppCoder gmail.com
 
 
 module eventpool;
 
 import std.c.windows.windows;
 
 extern (Windows)
 {
         HANDLE CreateEvent(
                 LPSECURITY_ATTRIBUTES lpEventAttributes,
                 BOOL bManualReset,
                 BOOL bInitialState,
                 LPCTSTR lpName
         );
 
         BOOL SetEvent(
                 HANDLE hEvent
         );
 
         BOOL ResetEvent(
                 HANDLE hEvent
         );
 }
 
 class Event
 {
         public HANDLE event;
 
         public this( bool manualReset, bool initialState )
         {
                 event = CreateEvent( null, manualReset, initialState, null );
         }
 
         public this()
         {
                 this( true, false );
         }
 
         public ~this()
         {
                 CloseHandle( event );
         }
 
         bool signalled()
         {
                 ulong waitRes;
                 waitRes = WaitForSingleObject( event, 0 );
 
                 return (waitRes == WAIT_OBJECT_0);
         }
 
         void signalled( bool isSignalled )
         {
                 if ( isSignalled )
                 {
                         SetEvent( event );
                 }
                 else
                 {
                         ResetEvent( event );
                 }
         }
 
         unittest
         {
                 Event ev = new Event();
                 ev.signalled = true;
                 assert( ev.signalled == true );
                 ev.signalled = false;
                 assert( ev.signalled == false );
 
                 delete ev;
         }
 }
 
 when compiling with "-unittest":
 eventpool.obj(eventpool)
  Error 42: Symbol Undefined _CreateEvent 16
 --- errorlevel 1
 
 
May 30 2006
parent akcom <CppCoder gmail.com> writes:
Don Clugston wrote:
 There's no CreateEvent() function in Windows.
 It's CreateEventW() or CreateEventA(), which then get aliased:
 
 extern (Windows)
 {
          HANDLE CreateEventW(
 ...
 }
 alias CreateEventW CreateEvent;
 
 
 
 d-bugmail puremagic.com wrote:
 http://d.puremagic.com/bugzilla/show_bug.cgi?id=169

            Summary: Compilation of module fails with -unittest
            Product: D
            Version: 0.159
           Platform: PC
         OS/Version: Windows
             Status: NEW
           Severity: normal
           Priority: P2
          Component: DMD
         AssignedTo: bugzilla digitalmars.com
         ReportedBy: CppCoder gmail.com


 module eventpool;

 import std.c.windows.windows;

 extern (Windows)
 {
         HANDLE CreateEvent(
                 LPSECURITY_ATTRIBUTES lpEventAttributes,
                 BOOL bManualReset,
                 BOOL bInitialState,
                 LPCTSTR lpName
         );

         BOOL SetEvent(
                 HANDLE hEvent
         );

         BOOL ResetEvent(
                 HANDLE hEvent
         );
 }

 class Event
 {
         public HANDLE event;

         public this( bool manualReset, bool initialState )
         {
                 event = CreateEvent( null, manualReset, initialState, 
 null );
         }

         public this()
         {
                 this( true, false );
         }

         public ~this()
         {
                 CloseHandle( event );
         }

         bool signalled()
         {
                 ulong waitRes;
                 waitRes = WaitForSingleObject( event, 0 );

                 return (waitRes == WAIT_OBJECT_0);
         }

         void signalled( bool isSignalled )
         {
                 if ( isSignalled )
                 {
                         SetEvent( event );
                 }
                 else
                 {
                         ResetEvent( event );
                 }
         }

         unittest
         {
                 Event ev = new Event();
                 ev.signalled = true;
                 assert( ev.signalled == true );
                 ev.signalled = false;
                 assert( ev.signalled == false );

                 delete ev;
         }
 }

 when compiling with "-unittest":
 eventpool.obj(eventpool)
  Error 42: Symbol Undefined _CreateEvent 16
 --- errorlevel 1
If I didn't feel stupid before...
May 31 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=169


CppCoder gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




-- 
May 31 2006