Git Product home page Git Product logo

Comments (2)

stevedonovan avatar stevedonovan commented on July 19, 2024

Yes, good point. llua.h must have extern "C" - I want to try it out in C++ mode for the Microsoft compiler anyway.

from llua.

jumogehn avatar jumogehn commented on July 19, 2024

I found a way lua takes for this kind of issue:

Because you can compile Lua both as C and as C++ code, lua.h does not include this typical adjustment code that is present in several other C libraries:

#ifdef __cplusplus
extern "C" {
#endif
   ...
#ifdef __cplusplus
}
#endif

Therefore, if you have compiled Lua as C code (the most common case) and are using it in C++, you must include lua.h as follows:
extern "C" {
#include <lua.h>
}
A common trick is to create a header file lua.hpp with the above code and to include this new file in your C++ programs.

But from 5.1 lua includes lua.hpp as shown below:

// lua.hpp
// Lua header files for C++
// <<extern "C">> not supplied automatically because Lua also compiles as C++

extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}

from llua.

Related Issues (2)

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.