Skip to content

Instantly share code, notes, and snippets.

@SimeonEhrig
Last active November 13, 2019 08:39
Show Gist options
  • Save SimeonEhrig/05bdb0927d5f799608a18034ee69449a to your computer and use it in GitHub Desktop.
Save SimeonEhrig/05bdb0927d5f799608a18034ee69449a to your computer and use it in GitHub Desktop.
Get arguments of a cling interpreter instance with reflection

To get the arguments of cling, which are passed on start, you can use the reflection feature of cling.

#include "cling/Interpreter/Interpreter.h"
#include "cling/Interpreter/InvocationOptions.h"

// gCling is an object of type cling::Interpreter
std::vector<const char*> remaining = gCling->getOptions().CompilerOpts.Remaining;
remaining
@SimeonEhrig
Copy link
Author

The solution for ROOT:

Workaround: use a cling build as the source for the necessary headers.

#pragma cling(add_include_path "/par/to/cling/install/include/")
#include "cling/Interpreter/Interpreter.h"

std::vector<const char*> remaining = cling::runtime::gCling->getOptions().CompilerOpts.Remaining;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment