2013-07-09 31 views
0

我有一个函数指针指向一个动态库,获取一个函数指针到C(C89)动态库

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

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

在GCCi686,苹果darwin10-GCC-4.2.1它一直工作,但在Visual Studio 2010上失败,

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

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

回答

1
#include <GL/gl.h> 

void (*vertex)(float, float); 

和明确地,

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

f ixes错误。