[Rivet] Plugin mechanism -- what do I do with the "extern" part?

Andy Buckley andy.buckley at durham.ac.uk
Mon Jul 13 17:02:31 BST 2009

Holger Schulz wrote:
> Hi,
> I wanted to try out Rivet's plug-in mechanism for analyses and I get stuck
> with error messages from g++ (4.3) of that kind:
>     error: ‘AnalysisBuilders’ does not name a type
> I have implemented my analysis following the plug-in example on the wiki
> page, except that I use a header file as well -- and this is where I get 
> stuck.
> Do I have to declare the extern "magic" in the header file as well?

I'm not quite sure what you've put where, without a couple of code
snippets, but the rationale for the 'extern "C"' bit is to declare the
plugin hook without C++ symbol mangling (i.e. in the unmangled style
used by the C language)

So the normal way to use the plugin system is for only the .cc file to
define and declare the "getAnalysisBuilders()" function, inside the
extern declaration. Note that this function is decoupled from the
analysis classes themselves.

Anyway, that's mostly for general interest about how the loader system
works... I suspect the real reason you are having build trouble is that
the AnalysisBuilders type is not known (it is an std::map of function
pointers, indexed by strings). Maybe you need to add '#include
"Rivet/AnalysisLoader.hh"' to the .cc file in which your extern
declaration of getAnalysisBuilders() is located?


Dr Andy Buckley
Institute for Particle Physics Phenomenology
Durham University
0191 3343798 | 0191 3732613 | www.insectnation.org

More information about the Rivet mailing list