当前位置:网站首页>Attempt to redefine 'timeout' at line 2 solution
Attempt to redefine 'timeout' at line 2 solution
2022-06-30 05:37:00 【Xiaomei】
Original code
local ffi = require("ffi")
ffi.cdef[[
struct timeval {
long int tv_sec;
long int tv_usec;
};
int gettimeofday(struct timeval *tv, void *tz);
]];
local gettimeofday_struct = ffi.new("struct timeval")
local function gettimeofday()
ffi.C.gettimeofday(gettimeofday_struct, nil)
return tonumber(gettimeofday_struct.tv_sec) * 1000000 + tonumber(gettimeofday_struct.tv_usec)
end
Operation error reporting
[error] 4028#0: *5 lua entry thread aborted: runtime error: /opt/olwaf/olaccess.lua:126: attempt to redefine 'timeval' at line 2
stack traceback:
coroutine 0:
[C]: in function 'cdef'
/opt/olwaf/olaccess.lua:126: in main chunk, client: 127.0.0.1, server: www.olwaf.com, request: "POST /api/v2/dict_info HTTP/1.1", host: "www.olwaf.com"
Normal after modification
local ffi = require("ffi")
if pcall(ffi.typeof, "struct timeval") then
-- check if already defined.
else
ffi.cdef[[
typedef struct timeval {
long tv_sec;
long tv_usec;
} timeval;
int gettimeofday(struct timeval* t, void* tzp);
]]
end
local gettimeofday_struct = ffi.new("struct timeval")
local function gettimeofday()
ffi.C.gettimeofday(gettimeofday_struct, nil)
return tonumber(gettimeofday_struct.tv_sec) * 1000000 + tonumber(gettimeofday_struct.tv_usec)
end
边栏推荐
- Rotating frame target detection mmrotate v0.3.1 training dota data set (II)
- Why can transformer break into the CV world and kill CNN?
- On line assignment of financial cost management in the 22nd spring of Western Polytechnic University [Full Score answer]
- UML tools
- Use of OpenCL thread algebra library viennacl
- Visualization of 3D geological model based on borehole data by map flapping software
- 86. 分隔链表
- 旋转框目标检测mmrotate v0.3.1入门
- C. Divan and bitwise operations
- Basic operations of C language
猜你喜欢
Solidity - Security - reentrancy attack
9. naive Bayes
token 过期后,如何自动续期?
The minecraft server address cannot be refreshed.
[note] usage model tree of the unity resource tree structure virtualizingtreeview
Delete the repeating elements in the sorting list (simple questions)
Access is denied encountered when vfpbs calls excel under IIS
Sound network, standing in the "soil" of the Internet of things
Remote sensing image /uda:curriculum style local to global adaptation for cross domain remote sensing image segmentation
Baiwen.com 7 days Internet of things smart home learning experience punch in the third day
随机推荐
[typescript] defines the return value type of promise
Introduction to mmcv common APIs
如何制作CSR(Certificate Signing Request)文件?
旋转框目标检测mmrotate v0.3.1入门
Unity ugui text value suspended enlarged display add text background
Array pointers and pointer arrays
Bessel curve with n control points
《谁动了我的奶酪》读后感
Baiwen.com 7 days Internet of things smart home learning experience punch in the third day
强烈推荐十几款IDEA开发必备的插件
Expansion method of unity scanning circle
Unity animator does not clip animation to play animation in segments
C语言基础小操作
Is it safe to open an account and trade with a compass?
[chestnut sugar GIS] global mapper - how to assign the elevation value of the grid to the point
Rotation, translation and scaling of unity VR objects
hashlips_ art_ Engine-1.0.6 usage
Unity scroll view element drag and drop to automatically adsorb centering and card effect
How to prevent source code leakage in enterprises and institutions
Digital signature——