lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I tried to build Lua with and without -D_FILE_OFFSET_BITS=64it did not help. Functions file:read() and file:write() work fine in this example:

local f = io.open("very_big_file.bin", "w+b")

print("1)", f:seek("end", -4))
f:write(string.pack("L", 12345678))

print("2)", f:seek("end", -4))
print("3)", string.unpack("L", f:read(4)))

print("4)", f:seek("set"))

f:close()

Output:

1)      -1
2)      -1
3)      12345678        5
4)      0

But file:seek() returns and takes the numbers of no more than 2^31-1. I do not see any other way except to override l_seeknum to 64-bit type.


2015-05-16 1:11 GMT+03:00 Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>:
> _FILE_OFFSET_BITS defined only in lprefix.h and no longer used anywhere.

Defining _FILE_OFFSET_BITS affects the inclusion of stdio.h, which is done
in liolib.c. That is the reason for lprefix.h: to define symbols *before*
including standard headers.