Comments (8)
Looks like you're compiling tinyexpr as C++. You need to compile it as C code, then link it into your C++ project.
from tinyexpr.
Also, this line is not what you want:
double result = te_interp("calc", 0);
To pass a C++ string to a C function, you would do something like this:
double result = te_interp(calc.c_str(), 0);
from tinyexpr.
Same error, but I think it could be from C & C++ incompatibilities.
from tinyexpr.
This is the full code then;
#include <stdio.h>
#include <math.h>
#include < iostream >
#include < string >
#include <stdlib.h>
#include <D:\ ... \Mywork\Cpp\Starter\tinyexpr.h>
#include <D:\ ... \Mywork\Cpp\Starter\tinyexpr.c>
int main()
{
std::cout << "Input arithmetic calculation: \n";
std::string calc;
std::cin >> calc;
double result = te_interp(calc.c_str(), 0);
std::cout << "Result = ";
std::cout << result << '\n';
return 0;
}
from tinyexpr.
How are you compiling?
from tinyexpr.
@EvilPudding Using Dev-C++ 5.11 with TDM GCC 4.9.2 64-bit
Compiler error;
D:\EvaxHybrid\Mywork\Cpp\Starter\tinyexpr.c: In function 'void pn(const te_expr*, int)':
D:\EvaxHybrid\Mywork\Cpp\Starter\tinyexpr.c:644:32: error: invalid conversion from 'void*' to 'const te_expr*' [-fpermissive]
pn(n->parameters[i], depth + 1);
^
D:\EvaxHybrid\Mywork\Cpp\Starter\tinyexpr.c:625:13: note: initializing argument 1 of 'void pn(const te_expr*, int)'
static void pn (const te_expr *n, int depth) {
^
from tinyexpr.
This line is your problem:
#include <D:\ ... \Mywork\Cpp\Starter\tinyexpr.c>
You need to remove that line! Then add tinyexpr.c to your project in your IDE. Your IDE should compile it separately as C code, and then link it in after.
As stated previously, your error comes from you compiling tinyexpr.c as C++, when it is in fact C code.
You should find a tutorial about how C and C++ compilers work. To be productive with programming, you need to not only know the programming language, but you need to understand how your tools work as well.
from tinyexpr.
@codeplea Ok, I will try it tonight.
from tinyexpr.
Related Issues (20)
- Feature request: add logical operators.
- Feature request : right and left shift operations HOT 4
- Look ahead Variables HOT 4
- Custom infix operators HOT 3
- How about support time expression? HOT 2
- Importing into gcc gives "error: array subscript has type 'char'" HOT 2
- The website says that this is a header-only library, but the actual code isn't HOT 2
- Extraction of tokens HOT 5
- Support for bigger whole numbers (long long) HOT 1
- When evaluate simple expression with only one variable, nan is returned over 150 HOT 6
- warning: ISO C forbids conversion of function pointer to object pointer type
- array bounds warning with gcc-11
- codeblocks compiler issue? HOT 2
- Weird behavior when calling te_free HOT 3
- Feature request: Add define to change return value from double to long double HOT 6
- Usage with different types HOT 2
- Feature Request: Implement ternary evalutation HOT 9
- Error eval expression when initializing te_variable by individual assignment HOT 7
- Function to determine the number of variables in an expression HOT 2
- Possible memory leak in te_compile HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tinyexpr.