0

I have a function pointer to a dynamic library,

#include <GL/gl.h> /* or something */ void (*vertex)(float, float) = &glVertex2f; 

On GCCi686-apple-darwin10-gcc-4.2.1 it's always worked, but fails on Visual Studio 2010 with,

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

I have it configured for C89; I believe that's the only C available. The idea is that I want to invoke the function pointer as an extern in other files that do not include the library headers.

2 Answers 2

1
#include <GL/gl.h> void (*vertex)(float, float); 

and explicitly,

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

fixes the error.

Sign up to request clarification or add additional context in comments.

Comments

0

Windows DLLs do not work like BSD/Linux shared libraries :(

I believe you need the GetProcAddress function.

This link was just pulled from Google: http://msdn.microsoft.com/en-us/library/ms683212(v=vs.85).aspx

1 Comment

This looks promising, but I am not including Windows.h if I can possibly avoid it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.