Help on passing a function to a function pointer.
Kirill
kirill.saidov at mail.com
Wed Mar 24 02:41:39 UTC 2021
I am exploring GLFW with D (bindbc-glfw). I faced the following
problem:
I need to set the frame buffer size callback:
`glfwSetFramebufferSizeCallback(GLFWwindow*, extern (C) void
function(GLFWwindow*, int, int) nothrow)`
I have created a function:
`extern (C) void setFrameBufferSizeCallback(GLFWwindow* window,
int w, int h) nothrow {
glfwViewport(0, 0, w, h);
}`
And then:
`glfwSetFramebufferSizeCallback(window,
&setFrameBufferSizeCallback)`
DMD produces the following error:
`source/display.d(59,32): Error: function pointer
glfwSetFramebufferSizeCallback(GLFWwindow*, extern (C) void
function(GLFWwindow*, int, int) nothrow)
is not callable using argument types
(GLFWwindow*, extern (C) void delegate(GLFWwindow* window, int w,
int h) nothrow)
source/display.d(59,32): cannot pass argument
&this.frameBufferSizeCallback of type extern (C) void
delegate(GLFWwindow* window, int w, int h) nothrow to parameter
extern (C) void function(GLFWwindow*, int, int) nothrow
dmd failed with exit code 1.
`
What should I do? I have read the available information on D
function pointers, but I still can't get it working. What am I
missing?
More information about the Digitalmars-d
mailing list