Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot compile luajit while using ISO C standards. #232

Open
SlawekNowy opened this issue May 27, 2024 · 1 comment
Open

Cannot compile luajit while using ISO C standards. #232

SlawekNowy opened this issue May 27, 2024 · 1 comment

Comments

@SlawekNowy
Copy link

gcc -MMD -MT build/linux-x64/release/obj/lj_str_hash.c/lj_str_hash.obj -MF build/linux-x64/release/obj/lj_str_hash.c/lj_str_hash.obj.d -std=c11 -O2 -Wall -fvisibility=hidden -I3rd/lua/luajit/src -DLUAJIT_UNWIND_EXTERNAL -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DLUA_MULTILIB="lib" -DLUAJIT_ENABLE_LUA52COMPAT -DLUAJIT_NUMMODE=2 -DNDEBUG -fno-stack-protector -U_FORTIFY_SOURCE -fPIC -msse4.2 -o build/linux-x64/release/obj/lj_str_hash.c/lj_str_hash.obj -c 3rd/lua/luajit/src/lj_str_hash.c
3rd/lua/luajit/src/lj_str_hash.c: In function ‘str_hash_init_random’:
3rd/lua/luajit/src/lj_str_hash.c:188:3: error: implicit declaration of function ‘srandom’; did you mean ‘srand’? [-Wimplicit-function-declaration]
  188 |   srandom(seed);
      |   ^~~~~~~
      |   srand
3rd/lua/luajit/src/lj_str_hash.c:197:24: error: implicit declaration of function ‘random’; did you mean ‘rand’? [-Wimplicit-function-declaration]
  197 |     random_pos[i][0] = random() & POW2_MASK(i+1);
      |                        ^~~~~~
      |                        rand

The code fails to account in the situation in which Linux user would compile with C standards (POSIX disabled).

@SlawekNowy
Copy link
Author

To fix this you would need the apply the following to lj_str_hash.c:49. Replace existing #if.

#if defined(__MINGW32__) || defined(_MSC_VER) || !(defined(_XOPEN_SOURCE) || defined(_DEFAULT_SOURCE))
#define random()  ((long) rand())
#define srandom(seed)  srand(seed)
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant