cellml / libcellml

Repository for libCellML development.
https://libcellml.org
Apache License 2.0
17 stars 21 forks source link

Generator: further refinements to the generated C code #938

Closed agarny closed 3 years ago

agarny commented 3 years ago
nickerso commented 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?

agarny commented 3 years ago

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.