Le samedi 27 février 2010 06:56:08, Vincent Torri a écrit : > On Sat, 27 Feb 2010, Peter Wehrfritz wrote: > > Gustavo Sverzut Barbieri wrote: > >> On Fri, Feb 26, 2010 at 6:33 PM, Peter Wehrfritz <peter.wehrfr...@web.de> wrote: > >>> Gustavo Sverzut Barbieri wrote: > >>>> On Fri, Feb 26, 2010 at 10:44 AM, Lucas De Marchi > >>>> > >>>> <lucas.demar...@profusion.mobi> wrote: > >>>>> C++ needs casts in order to assign a void* to another pointer type. > >>>>> As typeof operator is a gcc extension, we define EINA_TYPEOF(x) as > >>>>> "typeof" on gcc with c++ source and as nothing otherwise. > >>>> > >>>> Lucas, as I told you, I'd rather use the following patch, but it would > >>>> not help other C++ compilers, so not a real solution. > >>> > >>> What about this: > >>> > >>> template <typename T> > >>> inline T *cast_to(T *, void *p) > >>> { > >>> return (T *)p; > >>> } > >>> > >>> ... > >>> data = cast_to(data, l); > >>> > >>> I haven't used c++ since a while, but I think this should be portable. > >> > >> They have the fancy templates dynamic_cast<type>(ptr) and > >> static_cast<type>(ptr) > > > > Yes, I know. But I wasn't sure which one to chose, so I took a normal C > > cast as the OP did. > > static_cast is better that dynamic_cast in that case (imho)
Yes, static_cast is the most common cast operator and replaces the C-style casts. dynamic_cast will not work as it checks dynamically for the hierarchy class of both pointers. You should only use that with with polymorphic classes. > Vincent > > --------------------------------------------------------------------------- > --- Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > enlightenment-devel mailing list > enlightenment-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel > -- ------------------------ Raoul Hecky Calaos ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel