diff options
| author | Roberto I <roberto@inf.puc-rio.br> | 2025-09-05 15:36:47 -0300 |
|---|---|---|
| committer | Roberto I <roberto@inf.puc-rio.br> | 2025-09-05 15:36:47 -0300 |
| commit | 9ea06e61f20ae34974226074fc6123dbb54a07c2 (patch) | |
| tree | fe3333a7b89490be71b26047a5bc2d836113bf72 | |
| parent | ffbcadfb4197213d55222bca3ecc52606cd980f4 (diff) | |
| download | lua-9ea06e61f20ae34974226074fc6123dbb54a07c2.tar.gz lua-9ea06e61f20ae34974226074fc6123dbb54a07c2.tar.bz2 lua-9ea06e61f20ae34974226074fc6123dbb54a07c2.zip | |
Details
- LUAMOD_API defined as 'extern "C"' in C++.
- "ANSI C" is in fact "ISO C" (comments)
- Removed option -std from makefile in testes/libs. (Easier to change
to C++ for tests).
| -rw-r--r-- | lapi.c | 2 | ||||
| -rw-r--r-- | lmathlib.c | 2 | ||||
| -rw-r--r-- | loslib.c | 2 | ||||
| -rw-r--r-- | luaconf.h | 6 | ||||
| -rw-r--r-- | testes/libs/lib11.c | 2 | ||||
| -rw-r--r-- | testes/libs/makefile | 2 |
6 files changed, 11 insertions, 5 deletions
| @@ -484,7 +484,7 @@ LUA_API lua_State *lua_tothread (lua_State *L, int idx) { | |||
| 484 | 484 | ||
| 485 | /* | 485 | /* |
| 486 | ** Returns a pointer to the internal representation of an object. | 486 | ** Returns a pointer to the internal representation of an object. |
| 487 | ** Note that ANSI C does not allow the conversion of a pointer to | 487 | ** Note that ISO C does not allow the conversion of a pointer to |
| 488 | ** function to a 'void*', so the conversion here goes through | 488 | ** function to a 'void*', so the conversion here goes through |
| 489 | ** a 'size_t'. (As the returned pointer is only informative, this | 489 | ** a 'size_t'. (As the returned pointer is only informative, this |
| 490 | ** conversion should not be a problem.) | 490 | ** conversion should not be a problem.) |
| @@ -278,7 +278,7 @@ static int math_type (lua_State *L) { | |||
| 278 | */ | 278 | */ |
| 279 | 279 | ||
| 280 | /* | 280 | /* |
| 281 | ** This code uses lots of shifts. ANSI C does not allow shifts greater | 281 | ** This code uses lots of shifts. ISO C does not allow shifts greater |
| 282 | ** than or equal to the width of the type being shifted, so some shifts | 282 | ** than or equal to the width of the type being shifted, so some shifts |
| 283 | ** are written in convoluted ways to match that restriction. For | 283 | ** are written in convoluted ways to match that restriction. For |
| 284 | ** preprocessor tests, it assumes a width of 32 bits, so the maximum | 284 | ** preprocessor tests, it assumes a width of 32 bits, so the maximum |
| @@ -34,7 +34,7 @@ | |||
| 34 | #if defined(LUA_USE_WINDOWS) | 34 | #if defined(LUA_USE_WINDOWS) |
| 35 | #define LUA_STRFTIMEOPTIONS "aAbBcdHIjmMpSUwWxXyYzZ%" \ | 35 | #define LUA_STRFTIMEOPTIONS "aAbBcdHIjmMpSUwWxXyYzZ%" \ |
| 36 | "||" "#c#x#d#H#I#j#m#M#S#U#w#W#y#Y" /* two-char options */ | 36 | "||" "#c#x#d#H#I#j#m#M#S#U#w#W#y#Y" /* two-char options */ |
| 37 | #elif defined(LUA_USE_C89) /* ANSI C 89 (only 1-char options) */ | 37 | #elif defined(LUA_USE_C89) /* C89 (only 1-char options) */ |
| 38 | #define LUA_STRFTIMEOPTIONS "aAbBcdHIjmMpSUwWxXyYZ%" | 38 | #define LUA_STRFTIMEOPTIONS "aAbBcdHIjmMpSUwWxXyYZ%" |
| 39 | #else /* C99 specification */ | 39 | #else /* C99 specification */ |
| 40 | #define LUA_STRFTIMEOPTIONS "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%" \ | 40 | #define LUA_STRFTIMEOPTIONS "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%" \ |
| @@ -319,7 +319,13 @@ | |||
| 319 | ** More often than not the libs go together with the core. | 319 | ** More often than not the libs go together with the core. |
| 320 | */ | 320 | */ |
| 321 | #define LUALIB_API LUA_API | 321 | #define LUALIB_API LUA_API |
| 322 | |||
| 323 | #if defined(__cplusplus) | ||
| 324 | /* Lua uses the "C name" when calling open functions */ | ||
| 325 | #define LUAMOD_API extern "C" | ||
| 326 | #else | ||
| 322 | #define LUAMOD_API LUA_API | 327 | #define LUAMOD_API LUA_API |
| 328 | #endif | ||
| 323 | 329 | ||
| 324 | /* }================================================================== */ | 330 | /* }================================================================== */ |
| 325 | 331 | ||
diff --git a/testes/libs/lib11.c b/testes/libs/lib11.c index 377d0c48..6a85f4d6 100644 --- a/testes/libs/lib11.c +++ b/testes/libs/lib11.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #include "lua.h" | 1 | #include "lua.h" |
| 2 | 2 | ||
| 3 | /* function from lib1.c */ | 3 | /* function from lib1.c */ |
| 4 | int lib1_export (lua_State *L); | 4 | LUAMOD_API int lib1_export (lua_State *L); |
| 5 | 5 | ||
| 6 | LUAMOD_API int luaopen_lib11 (lua_State *L) { | 6 | LUAMOD_API int luaopen_lib11 (lua_State *L) { |
| 7 | return lib1_export(L); | 7 | return lib1_export(L); |
diff --git a/testes/libs/makefile b/testes/libs/makefile index 4e7f965e..cf4c6881 100644 --- a/testes/libs/makefile +++ b/testes/libs/makefile | |||
| @@ -5,7 +5,7 @@ LUA_DIR = ../../ | |||
| 5 | CC = gcc | 5 | CC = gcc |
| 6 | 6 | ||
| 7 | # compilation should generate Dynamic-Link Libraries | 7 | # compilation should generate Dynamic-Link Libraries |
| 8 | CFLAGS = -Wall -std=c99 -O2 -I$(LUA_DIR) -fPIC -shared | 8 | CFLAGS = -Wall -O2 -I$(LUA_DIR) -fPIC -shared |
| 9 | 9 | ||
| 10 | # libraries used by the tests | 10 | # libraries used by the tests |
| 11 | all: lib1.so lib11.so lib2.so lib21.so lib2-v2.so | 11 | all: lib1.so lib11.so lib2.so lib21.so lib2-v2.so |
