Why the API name used here is different from the original one?
Forgive me if this is a really simple question, but I am confused.
Inside lua-resty-libxl/lib/resty/libxl/types/book.lua, I find that the API is defined as BookHandle __cdecl xlCreateBookCA(void);.
But the API provided by the official net http://www.libxl.com/documentation.html?lang=cpp is xlCreateBook();.
Is this just because Lua links with c++ library in this way, by adding "CA" or "A"?
There are two versions of API, I will check but the other one used wchar_t if I remember correctly. I will recheck. We are using C API, not C++ API.
Okay, if you go there and download a package for your OS: http://libxl.com/download.html
There should be a directory called include_c. Inside that there are two different types of bindings, e.g. BookA.h and BookW.h. Here are examples:
BookA.h:
XLAPI BookHandle XLAPIENTRY xlCreateBookCA(void);
XLAPI BookHandle XLAPIENTRY xlCreateXMLBookCA(void);
XLAPI int XLAPIENTRY xlBookLoadA(BookHandle handle, const char* filename);
XLAPI int XLAPIENTRY xlBookSaveA(BookHandle handle, const char* filename);
BookW.h:
XLAPI BookHandle XLAPIENTRY xlCreateBookCW(void);
XLAPI BookHandle XLAPIENTRY xlCreateXMLBookCW(void);
XLAPI int XLAPIENTRY xlBookLoadW(BookHandle handle, const wchar_t* filename);
XLAPI int XLAPIENTRY xlBookSaveW(BookHandle handle, const wchar_t* filename);
As you can see other uses char* and the other uses wchar_t*. There is no xlCreateBook in C bindings.... but ...
... In libxl.h there are also defines:
#ifdef _UNICODE
// ...
#define xlCreateBook xlCreateBookCW
#define xlCreateXMLBook xlCreateXMLBookCW
#define xlBookLoad xlBookLoadW
#define xlBookSave xlBookSaveW
// ...
#else
// ...
#define xlCreateBook xlCreateBookCA
#define xlCreateXMLBook xlCreateXMLBookCA
#define xlBookLoad xlBookLoadA
#define xlBookSave xlBookSaveA
// ...
#endif
What we are doing here, is that we use explicitly the A-ones instead of W-ones.