On Thursday 26 April 2007 13:12, Leopold Toetsch wrote: > Am Donnerstag, 26. April 2007 16:43 schrieb Steve Peters:
> > - long * const out_array = mem_sys_allocate((sizeof (long)) * > > (arraylen + 1)); + long * const out_array = (long > > *)mem_sys_allocate((sizeof (long)) * (arraylen + 1)); > > I don't understand the rational for such patches nor the > mem_allocate_.*typed wrappers. malloc(3) and friends are returning a (void > *) pointer, a type which fits all memory related (i.e. non-function) > pointers. > > Did I miss something? Speaking practically, C++ compilers don't like implicit casts. On some platforms, the only good C compiler is a C++ compiler. Speaking pragmatically, I can't look at a structure full of void pointers or a variable declaration that uses void pointers as the type and tell what the code should or shouldn't do, and I expect that I'm not so strange among programmers myself. For the cost of a bit more typing (and only sometimes), the code works with more compilers and can be easier to understand. Meanwhile, yes, C still has the beautiful, well-designed, and above all, safe and clear type system of an assembly language that will core dump unless it knows exactly and only precisely how many bits of several dozen megabytes of memory, but we'll pretend that it actually matters to the compiler and runtime while it gives us the previous two benefits. -- c