tinyexpr
tinyexpr copied to clipboard
Compiling error : initializer is not a constant
I used visual studio 2015 to compile tinyexpr, but I got two compile errors(initializer is not a constant) when meet {"ceil", ceil, TE_FUNCTION1 | TE_FLAG_PURE, 0} and {"floor", floor, TE_FUNCTION1 | TE_FLAG_PURE, 0} line. It only happens under release, but there is nothing happed under debug mode.
Does it work if you just remove those two lines? i.e. compile without the ceil and floor functions?
yes, it works if I removed this two lines.
Is it possible that you're compiling this as C++ instead of C? I think that may be the issue here.
Oh, yes, I used it in my C++ project. But I didn't change the file extension from .c to .cpp, the compiler(vs 2015) supposes to compile it as C, right?
I'm not sure about that. It probably depends on the project settings. You could add some C++ code to the file to check if it is indeed compiling as C++ or not.
Look at this commit: https://github.com/codeplea/tinyexpr/pull/47/commits/085d6782613ba4458cce3b43389d5bad58a81ca0 It seems to have a fix for your problem in tinyepr.c:173
This has been fixed in commit 96b85c1a77cabffddf405a72a15945815c65897f (closing issue #34 that was exactly the same as this one).