0

I think that many people faced problems linked to some missing header file or library and find themselves with the compiler complaining about some undefined symbol or saying that some function has not been defined in the current scope...Furthermore, I think that reading and understanding others source code require at least grasping the used functions and thus the corresponding headers (as you may stumble upon "partial" code...).

I wonder whether reflection (or other features) offers the capability to dynamically introspect the imported headers within the current execution scope for a C++ source file?

(I'm targeting especially C++ interpreters like Cling or Ch, as interpreters do not allow full control over imported headers and many things are done in the background.)

Ðаn
  • 10,934
  • 11
  • 59
  • 95
jihed gasmi
  • 279
  • 4
  • 9
  • 1
    Succinctly, "No". Or, at least, probably not. Especially in compilers — and I know you said interpreters, so that might alter the answer, but probably won't. – Jonathan Leffler Mar 29 '21 at 17:34
  • If you compile with a recent [GCC](http://gcc.gnu.org/) (e.g. GCC10 at least), compile [with](https://gcc.gnu.org/onlinedocs/gcc/Invoking-GCC.html) `g++ -H` or code your [GCC plugin](https://gcc.gnu.org/onlinedocs/gccint/Plugins.html). Look also into [RefPerSys](http://refpersys.org/), [bismon](http://github.com/bstarynk/bismon) and contact me by email to `basile@starynkevitch.net` – Basile Starynkevitch Mar 29 '21 at 17:37
  • 1
    Isn't missing header immediately compile error? – apple apple Mar 29 '21 at 17:56
  • @apple apple,it seems that i wasn't succesful in explaining my idea :I'm trying to identify Ch imported headers "by default" and understanding what is happening under the hood of the interpreter - Ch does not allow to write #include directive as it's programmed to import some standard headers thus some standard functions – jihed gasmi Mar 29 '21 at 20:18
  • I never use `ch` so just some thought, but headers are just codes to be injected into current file. You can declare them yourself without any header file. So I think list header would have little help over tell you symbols are undefined. – apple apple Mar 30 '21 at 07:30

0 Answers0