C++在EXE DLL边界上使用指针

发布于 2025-02-11 11:10:22 字数 625 浏览 0 评论 0原文

我专门与GLFW合作,但希望这是关于EXE和DLL边界的一个普遍问题。

我试图将glfwwindow*从DLL传递到Windows Dev Env中的EXE。

这里是一个简化的片段:

*inside main.cpp in the exe:*
    GLFWwindow* w = dllClass.getGLFWWindowPointer() 
    int display_w, display_h;
    if (w)
        glfwGetFramebufferSize(w, &display_w, &display_h); 

指针返回而不是null,它被称为framebuffersize func,但是display_w运行后为0。 (并且在DLL中的类调用同一代码时是正确的)

请注意,DLL中的类用__declSpec(dllexport)标记。查看GLFW代码库,GLFWWINDOW是一个带有一堆上下文信息的结构,并且GLFWGetFrameBuffersize函数本身在GLFW DLL中也标有__declSpec(dllexport),不确定这是否特别相关。

我真的在EXE和DLL屏障细节上,如果问题出在GLFW代码中或我的目的中,所以不确定下一步要去哪里。

Im working with glfw specifically, but hopefully this is a general question about exe and dll boundaries.

Im trying to pass a GLFWwindow* from a dll to an exe in a windows dev env.

Here a simplified snippet:

*inside main.cpp in the exe:*
    GLFWwindow* w = dllClass.getGLFWWindowPointer() 
    int display_w, display_h;
    if (w)
        glfwGetFramebufferSize(w, &display_w, &display_h); 

The pointer gets returned and is not null, that ..FramebufferSize func is being called, but the display_w is 0 after it runs. (and are correct when this same code is called by a class within the dll)

Note that the classes in the dll are marked with __declspec(dllexport). Looking at the glfw codebase, that GLFWwindow is a struct with a bunch of context info and the glfwGetFramebufferSize function itself within the glfw dll is also marked with __declspec(dllexport), not sure if that's particularly relevant.

I'm really fuzzy on exe and dll barrier specifics, and if the problem is in the glfw code or on my end, so unsure where to go next.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文