Code Monkey home page Code Monkey logo

Comments (8)

codeplea avatar codeplea commented on August 27, 2024

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.

codeplea avatar codeplea commented on August 27, 2024

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.

kornkaobat avatar kornkaobat commented on August 27, 2024

Same error, but I think it could be from C & C++ incompatibilities.

from tinyexpr.

kornkaobat avatar kornkaobat commented on August 27, 2024

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.

EvilPudding avatar EvilPudding commented on August 27, 2024

How are you compiling?

from tinyexpr.

kornkaobat avatar kornkaobat commented on August 27, 2024

@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.

codeplea avatar codeplea commented on August 27, 2024

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.

kornkaobat avatar kornkaobat commented on August 27, 2024

@codeplea Ok, I will try it tonight.

from tinyexpr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.