Thread overview | ||||||
---|---|---|---|---|---|---|
|
May 31, 2006 [Bug 169] New: Compilation of module fails with -unittest | ||||
---|---|---|---|---|
| ||||
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 31, 2006 Re: [Bug 169] New: Compilation of module fails with -unittest | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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 31, 2006 [Bug 169] Compilation of module fails with -unittest | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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 Re: [Bug 169] New: Compilation of module fails with -unittest | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don Clugston | 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...
|
Copyright © 1999-2021 by the D Language Foundation