Stange Exceptions with Delegates
torhu
no at spam.invalid
Fri Jan 11 16:34:49 PST 2008
Trevor Parscal wrote:
> Im experiencing a very strange behavior with delegates. When using some OpenGL functions in a delegate my program will give me
>
> object.Exception: Access Violation
> - when there's a Cout call at the begining and end of the delegate
>
> object.Exception: Win32 Exception
> - when it's only OpenGL calls in the delegate
>
> The strangest part is that the Cout calls will succeed in printing to the console, meaning the access violation isn't in the OpenGL calls. I also placed some Cout calls before and after the actual calling of the delegate, and the first prints, while the second (post delegate calling) never does.
>
> So what could be happening between the last call inside of a delegate and the delegate being done?
Are you on windows? A typical mistake is calling openGL functions using
the cdecl calling convention, you need to use stdcall. stdcall is
'extern (Windows)' or 'extern (System)' in D. Mixing up calling
conventions leads to stack corruption, and then usually a crash sooner
or later after the function returns.
More information about the Digitalmars-d
mailing list