FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to use callbacks?

 
Post new topic   Reply to topic     Forum Index -> Core32
View previous topic :: View next topic  
Author Message
Abscissa



Joined: 23 Feb 2005
Posts: 40
Location: Cleveland, OH, US

PostPosted: Sun Feb 19, 2006 12:35 am    Post subject: How to use callbacks? Reply with quote

I'm having trouble using a callback:

callback.d:
Code:
import win32.api;

extern(Windows) BOOL EnumWindowsProc(HWND hwnd, LPARAM lParam)
{

} // line 6

int main(char[][] args)
{
    EnumWindows(&EnumWindowsProc, 0);

    return 0;
}


That compiles fine, but when I run it I get:

Code:
Error: AssertError Failure callback(6)
Back to top
View user's profile Send private message
AgentOrange



Joined: 21 Jul 2005
Posts: 61

PostPosted: Sun Feb 19, 2006 12:48 am    Post subject: Reply with quote

the callback needs to return a bool.
Back to top
View user's profile Send private message
Abscissa



Joined: 23 Feb 2005
Posts: 40
Location: Cleveland, OH, US

PostPosted: Sun Feb 19, 2006 12:53 am    Post subject: Reply with quote

LOL, nevermind, I'm an idiot Smile

Code:
import win32.api;

extern(Windows) BOOL EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
    [b]return TRUE;[/b]
}

int main(char[][] args)
{
    EnumWindows(&EnumWindowsProc, 0);

    return 0;
}
Back to top
View user's profile Send private message
Abscissa



Joined: 23 Feb 2005
Posts: 40
Location: Cleveland, OH, US

PostPosted: Sun Feb 19, 2006 12:54 am    Post subject: Reply with quote

Although I have to say, I'm really surprised the compiler didn't catch that.
Back to top
View user's profile Send private message
AgentOrange



Joined: 21 Jul 2005
Posts: 61

PostPosted: Sun Feb 19, 2006 2:55 am    Post subject: Reply with quote

Abscissa wrote:
Although I have to say, I'm really surprised the compiler didn't catch that.


Welcome to D Smile

I believe this is because walter allows you to have paths that do not return a value - as long as its never called. Why - who knows. Therefore he just asserts at runtime. And yes, just about everyone but walter wants it to at least say "YOU FORGOT TO RETURN". Its just one of those things you remember after a while...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Core32 All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group