lua-users home
lua-l archive

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


eugeny gladkih <john@gladkih.com> writes:
>   // get rid of idiotic g++ warning
>   template<class T> T symbol( const char *symbol_name ) const {
>     return depun_ptr<T>( get_symbol( symbol_name ) );
>   }

It can be annoying to be sure, but I'm not sure if "idiotic" is fair --
the standard really does say the two pointer types aren't compatible
(and there are reasons for that).  If you use the -pedantic option, well
the compiler is pedantic.... :-)

To get around the warning in C though, you could just use an
intermediary integer type, hopefully something long enough to hold a
pointer, e.g., intptr_t:

 #include <stdint.h>

    void *dptr = ...;
    void (*fptr)() = (void (*)())(intptr_t)dptr;

That doesn't give a warning with gcc -pedantic, unless "intptr_t" is a
different size than a function pointer, in which case it will give a
warning (which is probably what you want).

-Miles

-- 
Absurdity, n. A statement or belief manifestly inconsistent with one's own
opinion.