[prev in list] [next in list] [prev in thread] [next in thread] 

List:       enlightenment-devel
Subject:    Re: [E-devel] [PATCH] Use casts when using cpp
From:       Vincent Torri <vtorri () univ-evry ! fr>
Date:       2010-02-27 5:56:08
Message-ID: Pine.LNX.4.64.1002270652360.27762 () grozny ! maths ! univ-evry ! fr
[Download RAW message or body]



On Sat, 27 Feb 2010, Peter Wehrfritz wrote:

> Gustavo Sverzut Barbieri wrote:
>> On Fri, Feb 26, 2010 at 6:33 PM, Peter Wehrfritz <peter.wehrfritz@web.de> wrote:
>>
>>> Gustavo Sverzut Barbieri wrote:
>>>
>>>> On Fri, Feb 26, 2010 at 10:44 AM, Lucas De Marchi
>>>> <lucas.demarchi@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)

Vincent

------------------------------------------------------------------------------
Download Intel&#174; 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
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic