Skip to content

Please help with this very simple native library #455

Closed Answered by iahung2
iahung2 asked this question in Q&A
Discussion options

You must be logged in to vote

Missing load_lib and unload_lib. I used to think they are optional.

#include "../../vm/lib_api.h"
#include "../../shared/sys.h"

extern "C" {

	//
	// initialize library
	//
#ifdef _WIN32
	__declspec(dllexport)
#endif
	void load_lib(VMContext& context) {
	}

	//
	// release library
	//
#ifdef _WIN32
	__declspec(dllexport)
#endif
	void unload_lib() {
	}

#ifdef _WIN32
	__declspec(dllexport)
#endif
	void test_func(VMContext& context) {
		const auto x = APITools_GetIntValue(context, 1);
		const auto y = APITools_GetIntValue(context, 2);
		APITools_SetIntValue(context, 0, x + y);
	}
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by iahung2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant