argppp::inst ()
{
static argppp my
- (global_opts, dwarflint::main_registrar ()->get_descriptors ());
+ (global_opts (), dwarflint::main_registrar ()->get_descriptors ());
return my;
}
argppp::parse (int argc, char **argv, unsigned flags, int *remaining)
{
assert (!_m_inited);
- argp_parse (&_m_argp, argc, argv, flags, remaining, &global_opts);
+ argp_parse (&_m_argp, argc, argv, flags, remaining, &global_opts ());
}
void
, _m_seen (false)
{}
-options global_opts;
+// Trick to make sure the static options are always initialized
+// before access (it is used from various global initializers.
+
+options &
+global_opts ()
+{
+ static options inst;
+ return inst;
+}
typedef xoption<std::string> string_option;
typedef xoption<unsigned> unsigned_option;
-extern options global_opts;
+options & global_opts ();
template<class OPT>
struct global_opt
global_opt (Args const&... args)
: OPT (args...)
{
- global_opts.add (this);
+ global_opts ().add (this);
}
};