0

Is there any way to access a function defined in a specific header file?

For example, in java, you can do:

Method m = Object.class.getMethod("foo", null);
Object result = m.invoke(null);

Is there any way to just pull all functions from a header, and then execute them one at a time?

  • 2
    no, header files are just lists of declarations. on POSIX systems you could do a bunch of string parsing and then `dlopen` and `dlsym` a library but it wouldn't be anything close to what you need. C doesn't have the reflection mechanisms necessary. – Ryan Haining May 11 '14 at 05:01
  • you probably need a building system with conditionals to perform something like that, for example `cmake`. – user2485710 May 11 '14 at 05:03
  • or use `libdl` http://stackoverflow.com/questions/2882771/plugin-architecture-in-c-using-libdl , it depends on what you need and when. – user2485710 May 11 '14 at 05:06
  • 2
    Looks more like a LoadLibrary/dlopen and GetProcAddress/dlsym feature that you are looking for. – cup May 11 '14 at 05:08

0 Answers0