Stange Exceptions with Delegates
Trevor Parscal
trevorparscal at hotmail.com
Sat Jan 12 01:29:15 PST 2008
Trevor Parscal Wrote:
> torhu Wrote:
>
> > 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.
>
> Excelent advice, and after looking at other opengl bindings you are absolutely right... However.
>
> I am using implib to generate a .lib from my opengl32.dll on my system - and the only way I can get a compile without linking errors is to use extern(C)
>
> I have tried using the /s flag and not - no difference in behavior. Any ideas of what I could do to fix this?
I found these def files as referred to in this post
http://www.digitalmars.com/d/archives/digitalmars/D/12896.html
which solved my problem. Thanks for the help!
More information about the Digitalmars-d
mailing list