codeplea / tinyexpr

tiny recursive descent expression parser, compiler, and evaluation engine for math expressions
https://codeplea.com/tinyexpr
zlib License
1.61k stars 245 forks source link

warning: ISO C forbids conversion of function pointer to object pointer type #86

Open stcmeh opened 3 years ago

stcmeh commented 3 years ago

I think that this warning arises because some CPU architectures have different memory bus sizes for code memory and data memory. Your code uses a single pointer to point to either functions or data with a second flag to indicate what the pointer means. The use of a single pointer type (void *) causes the compiler warning.

I tried just doing simple type-casting e.g. on line 161:

{"abs",   (void *)fabs,   TE_FUNCTION1 | TE_FLAG_PURE, 0},

But that didn't work.

Maybe a union would work? Not sure. Or you'd need to have two pointers in te_variable.

As far as I know the code still works but it creates lots of warnings.

Thanks for any help with this.