Closed agarny closed 3 years ago
I'm not completely convinced about removing the casting of malloc()
. Have we tested that our traditional LLVM-based dynamic compilation of the generated code is happy with that?
I tried it in OpenCOR. I normally treat warnings as errors and neither
double * createVariablesArray()
{
return (double *) malloc(3*sizeof(double));
}
nor
double * createVariablesArray()
{
return malloc(3*sizeof(double));
}
can be compiled. However, if I don't treat warnings as errors, then both can be compiled just fine.
So, yes, it's all fine and the suggested change means that the code respect the C standard even more.
VariableInfo
structure (this was an oversight on my part in #901).malloc()
is redundant (see here). To cast would normally allow our generated C code to be compilable by a C++ compiler, but then again any decent C++ compiler would complain our use ofmalloc()
/free()
. So, we may as well stick to the C standard.