Comments (4)
Hello and thank you for trying to use my work.
I'm sorry, I realize the mistake I made, when you want to call a C++ function in Lua you have to use the lua API, so the add
function in the example should look like this:
int add(lua_State *l)
{
int n = lua_gettop(l); // get the number of arguments
if (n != 2) {
lua_pushliteral(l, "bad number of arguments");
lua_error(l);
}
int a = lua_tointeger(l, 1); // get first argument
int b = lua_tointeger(l, 2); // get second argument
std::cout << "[C++] " << a << " + " << b << std::endl;
lua_pushinteger(l, a + b); // the return value
return 1; // number of argument returned
}
If you are at the root of the repository then you can compile that way:
make libluaincpp.a
g++ main.cpp -lluaincpp -lua -Isrc
./a.out
Tell me how it goes
from lua-in-cpp.
I updated the repository and provided a way to compile the README example, now you only have to do make test
from lua-in-cpp.
Thank you for the update, but I moved to sol3.
from lua-in-cpp.
Yeah, that's what I was afraid of 😅 The goal when I created this library was to have a simple way to call functions from one language to the other compared to sol3. If you're feeling adventurous you can try this library again 😊
from lua-in-cpp.
Related Issues (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 lua-in-cpp.