[gtkmm] Glib::Module::get_symbol and void pointer akwardness



In order to use get_symbol(), you always have to use a temporary void
pointer, which seems.. akward.  I suppose this is a result of the
underlying dlsym() using void pointers, and in the end, it seems there
is no way to really have type safety while using dynamically loaded
modules. :/

But instead of:

    void * func;
    if(mod.get_symbol("some_function", func))
        ((my_function_type) func_v)();

Why not:

    my_function_type func;
    if(mod.get_symbol("some_function", func))
        func();

?

get_symbol() could be something like:

    tempate<typename SymbolPtr>
    bool get_symbol(const std::string& symbol_name, SymbolPtr& symbol)

Whereas it is currently:

    bool get_symbol(const std::string& symbol_name, void *& symbol)

There may be other issues here that I'm not aware of, but this seemed to
stick out to me.

-- 
Nick Welch aka mackstann | mack @ incise.org | http://incise.org
Must I hold a candle to my shames?
		-- William Shakespeare, "The Merchant of Venice"



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]