c++cluaffiluajit

Can I make function `extern "c"`?


I have some cpp files, and I want to combine them with LuaJit using FFI.

But the problem is that, I have to add extern "c" symbols for almost every function to make it possible for FFI to access them.

Is there a simpler way to make this done?


Solution

  • Several functions can be placed inside a single extern "C" block. This allows you to type extern "C" only once for each header file.

    extern "C" {
        void function1();
        void function2();
    }