lrexlib icon indicating copy to clipboard operation
lrexlib copied to clipboard

C++11

Open alex-mashin opened this issue 10 years ago • 4 comments

When statically included within C++11 projects, the library isn't compiled.

The errors are:

.../luasandbox/include/lrexlib-2.6.0/src/pcre/../algo.h:125:27: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] luaL_typerror(L, pos, "string or "REX_TYPENAME);

and

.../luasandbox/include/lrexlib-2.6.0/src/pcre/lpcre.c:180:20: error: invalid conversion from ‘void_’ to ‘const unsigned char_’ [-fpermissive] argC->tables = *check_chartables (L, pos);

There may be other errors.

alex-mashin avatar Feb 22 '15 17:02 alex-mashin

Thanks for the report; can you try again with up-to-date sources? Also, I'm a little confused: lrexlib is C, not C++.

rrthomas avatar Jun 20 '15 09:06 rrthomas

This is the problem: lrexlib's C is not up to C++'s standards, therefore it cannot be compiled statically into projects in C++.

alex-mashin avatar Jun 21 '15 09:06 alex-mashin

Lua is written in the intersection of C and C++. lrexlib, like most Lua libraries, is written in plain C. You can use it statically (or dynamically!) in a C++ project just as you would any other C++: using extern "C".

Compiling lrexlib (or any other Lua C library that calls other C libraries) as C++ would require considerable work, because then the bindings to the C libraries (libc, oniguruma, TRE &c.) would need to have both C++ and C versions. It does sound like an interesting project to try to find a general solution; feel free to propose patches.

rrthomas avatar Jun 21 '15 12:06 rrthomas

@alex-mashin I've fixed some minor issues. Could you please try again?

shmuz avatar Jun 21 '15 12:06 shmuz