[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Warning with Lua 5.1.3 sources (gcc -pedantic)
- From: Miles Bader <miles.bader@...>
- Date: Thu, 13 Mar 2008 12:12:50 +0900
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.