Re: [ooc-compiler] C interface problems
Brought to you by:
mva
|
From: Stewart G. <sgr...@ii...> - 2004-11-04 12:18:13
|
Hi August,
> One potential problem: the glut functions are defined as "APIENTRY",
> which under Windows means that they use the "stdcall" calling
> convention rather than "cdecl". Therefore, you should probably specify
> "Pascal" rather than "C" as your interface type. That is:
> MODULE Glut [INTERFACE "Pascal"; LINK LIB "glut32"; LIB "opengl32";
> END];
> I think the same goes for the other GL modules. Presuming that the
> linker knows the procedure attributes, that may be why it is giving
> the error (ie. the procedure name matches, but the attributes are
> wrong).
I ran a quick check, and it looks like this is indeed what happens. The
following should compile and link fine. It also runs OK, opening a
window and correctly calling the display procedure.
MODULE Test;
IMPORT C, Glut;
VAR w: C.int;
PROCEDURE Display ["Pascal"];
END Display;
BEGIN
w := Glut.CreateWindow("OpenGL Test");
Glut.DisplayFunc(Display);
Glut.MainLoop
END Test.
MODULE Glut [INTERFACE "Pascal"; LINK LIB "glut32"; LIB "opengl32";
END];
IMPORT C;
TYPE
DisplayCallback = PROCEDURE;
PROCEDURE ["glutCreateWindow"] CreateWindow*(title: ARRAY OF C.char):
C.int;
PROCEDURE ["glutDisplayFunc"] DisplayFunc*(p: DisplayCallback);
PROCEDURE ["glutMainLoop"] MainLoop*;
END Glut.
Hope this helps.
Cheers,
Stewart
|