2013-07-09 34 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錯誤。