digitalmars.D - Stange Exceptions with Delegates
- Trevor Parscal (8/8) Jan 11 2008 Im experiencing a very strange behavior with delegates. When using some ...
- torhu (6/17) Jan 11 2008 Are you on windows? A typical mistake is calling openGL functions using...
- Trevor Parscal (4/22) Jan 12 2008 Excelent advice, and after looking at other opengl bindings you are abso...
- Trevor Parscal (4/30) Jan 12 2008 I found these def files as referred to in this post
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 there any other methods of tracking down the problem?
Jan 11 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.
Jan 11 2008
torhu Wrote:Trevor Parscal wrote: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?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.
Jan 12 2008
Trevor Parscal Wrote:torhu Wrote: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!Trevor Parscal wrote: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?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.
Jan 12 2008