0

我有一个指向动态库的函数指针,

#include <GL/gl.h> /* or something */

void (*vertex)(float, float) = &glVertex2f;

在 GCCi686-apple-darwin10-gcc-4.2.1 上它一直有效,但在 Visual Studio 2010 上失败了,

error 'vertex': address of dllimport 'glVertex2f' is not static

我已经为 C89 配置了它;我相信这是唯一可用的 C。这个想法是我想extern在不包含库头的其他文件中调用函数指针。

4

2 回答 2

1
#include <GL/gl.h>

void (*vertex)(float, float);

并且明确地,

int main(int argc, char **argv) {
    vertex = &glVertex2f;
    ...
}

修复错误。

于 2013-07-10T17:08:20.003 回答
0

Windows DLL 不像 BSD/Linux 共享库那样工作:(

我相信你需要这个GetProcAddress功能。

此链接刚刚从 Google 中提取:http: //msdn.microsoft.com/en-us/library/ms683212 (v=vs.85).aspx

于 2013-07-10T10:44:24.653 回答