cloudwu / sproto

Yet another protocol library like google protocol buffers , but simple and fast.
MIT License
942 stars 253 forks source link

lua_tointeger return int32 in lua51 #86

Closed gjy1606 closed 5 years ago

cloudwu commented 5 years ago

lua_tointeger returns ptrdiff_t in lua 5.1 by default, it's the same word width as void * , you can change it in luaconf.h .

I guess you need a 64bit integer in 32bit platform.

But changing the behavior of lua_tointegerx is not enough , you should change the lua_tointeger and lua_pushinteger of lua 5.1 if you want to change the the presentation of integer .

gjy1606 commented 5 years ago

没有猜错, 我确实是在 32 位机器上想要使用 64 位的 int. 看来这个修改太欠考虑了, 不过我若直接修改 luaconf.h 的话会使整个项目的 LUA_INTEGER 被修改, 只想修改 sproto 里面对应的 int 为 64 位的. 另 https://github.com/cloudwu/sproto/blob/d7e4b7bce7d4f456d76453c5b296d78b50f278ec/lsproto.c#L59-L75 lua_absindex 在 lua51 中并未定义, 直接兼容到 lua51 的项目中会报错. 不知道以下修改是否可行, 若可行的话我直接修改我的本地项目吧, 准备 close pr 了.

cloudwu commented 5 years ago

建议直接改 lua_Integer 的定义。

cloudwu commented 5 years ago

https://github.com/cloudwu/sproto/commit/17affafb4c58d6f08d6a50a43814fc5b723914e6 看看这个。

gjy1606 commented 5 years ago

好的, 我直接按这个改吧, 直接 close pr 了.