tinyexpr icon indicating copy to clipboard operation
tinyexpr copied to clipboard

Compiling error : initializer is not a constant

Open shawneeshaw opened this issue 3 years ago • 7 comments

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.

shawneeshaw avatar Apr 15 '21 04:04 shawneeshaw

Does it work if you just remove those two lines? i.e. compile without the ceil and floor functions?

codeplea avatar Apr 15 '21 15:04 codeplea

yes, it works if I removed this two lines.

shawneeshaw avatar Apr 15 '21 23:04 shawneeshaw

Is it possible that you're compiling this as C++ instead of C? I think that may be the issue here.

codeplea avatar May 23 '21 23:05 codeplea

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?

shawneeshaw avatar May 24 '21 00:05 shawneeshaw

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.

codeplea avatar May 24 '21 14:05 codeplea

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

equilibr avatar Jul 20 '21 23:07 equilibr

This has been fixed in commit 96b85c1a77cabffddf405a72a15945815c65897f (closing issue #34 that was exactly the same as this one).

bavay avatar Oct 04 '21 07:10 bavay