hello,
i`m new here and to pspdev,
i was playing with some source code,
i wanted to mix some examples, one of which in c another in c++,
i get only one error about invalid conversion
from this line (taken from c example):
struct Vertex* vertices = sceGuGetMemory((NUM_VERTICES+1) * sizeof(struct Vertex));
any ideas how to do it in c++
i would be very grateful for any help,
thanks,
wojciech
vertex* conversion in c++
-
- Posts: 171
- Joined: Mon Nov 14, 2005 1:32 am
- Location: Boston, Massachusetts
- Contact:
The compiler is just warning you (forcefully) that you are taking a pointer to an anonymous block of memory and using it as a specific type. Just use a "cast" to tell the compiler that you know what you are doing:
struct Vertex* vertices = (struct Vertex*)sceGuGetMemory((NUM_VERTICES+1) * sizeof(struct Vertex));
Hope this helps!
struct Vertex* vertices = (struct Vertex*)sceGuGetMemory((NUM_VERTICES+1) * sizeof(struct Vertex));
Hope this helps!
sceGuGetMemory() returns type void *. You're assigning it to type struct Vertex *.
In C, all pointer types are compatible with void *, so you can just make the assignment.
In C++ the cast is mandatory, as Dr.Vegetable has shown.
One very common place this happens is when C++ programs use malloc, which also returns void *.
Jim
In C, all pointer types are compatible with void *, so you can just make the assignment.
In C++ the cast is mandatory, as Dr.Vegetable has shown.
One very common place this happens is when C++ programs use malloc, which also returns void *.
Jim