tags:

views:

37

answers:

2

I thought I read about a C standard library function recently that was able to return a pointer to any extern variable whose name was passed to it as a const char *. I think that it works via linker symbols, if that helps.

+2  A: 

You could be thinking of dlsym, which is not part of the C standard library but part of the POSIX API.

dreamlax
Yup, this looks like it. My mistake in thinking it was a C standard thing, POSIX is pretty close ;)
Jared P
+2  A: 

It depends on the system. dlsym has already been mentioned. Its Windows counterpart is GetProcAddress. In the latter case, the function needs to be not only external but exported.

Jerry Coffin
+1, I was going to mention `GetProcAddress` also but he mentioned "standard library" so I ruled Windows API out.
dreamlax
@dreamlax: +1 for considering POSIX "more standard" than Windows API ;)
RWS