当前位置:网站首页>Lua uses require to load the shared library successfully, but the return is Boolean (always true)
Lua uses require to load the shared library successfully, but the return is Boolean (always true)
2022-07-06 03:11:00 【iMatt】
First look at require Help document for
If the loader returns any non-nil value,
require
assigns the returned value topackage.loaded[modname]
. If the loader does not return a non-nil value and has not assigned any value topackage.loaded[modname]
, thenrequire
assigns true to this entry
The meaning of this sentence is : If the loader returns a non null value , Then assign this non null value to package.loaded[modname] That is to say require The return value of . If the loader no return value , Then it will be assigned a true.
that , Why? loader There is no return value ? Nothing but 2 Medium condition
xxx.so( or xxx.dll) The agreed interface of the shared library int luaopen_xxx function
1、 Not to lua The stack returns nothing , That is, there is no direction lua Export any function .
2、 Export content , But I didn't tell lua.luaopen_xxx Signature compliance lua_CFunction, The passage of this function
returns in C the number of results( use C The number of results returned by the language ).
That is to say luaopen_xxx The return value of must not be 0, Usually export function table ,return 1.
边栏推荐
- [padding] an error is reported in the prediction after loading the model weight attributeerror: 'model' object has no attribute '_ place‘
- Mysql database operation
- Tomb. Weekly update of Finance (February 7 - February 13)
- Data and Introspection__ dict__ Attributes and__ slots__ attribute
- My C language learning records (blue bridge) -- files and file input and output
- Redis SDS principle
- OCR文字識別方法綜述
- Fault analysis | analysis of an example of MySQL running out of host memory
- Installation and use tutorial of cobaltstrike-4.4-k8 modified version
- 1003 emergency (25 points), "DIJ deformation"
猜你喜欢
随机推荐
Sign SSL certificate as Ca
Audio-AudioRecord Binder通信机制
Misc (eternal night), the preliminary competition of the innovation practice competition of the National College Students' information security competition
Microservice registration and discovery
OCR文字識別方法綜述
CSP numeric sort
【若依(ruoyi)】启用迷你导航栏
继承day01
Analyze menu analysis
Pat 1046 shortest distance (20 points) simulation
mysqldump数据备份
手写数据库客户端
Installation and use tutorial of cobaltstrike-4.4-k8 modified version
tcpdump: no suitable device found
Codeworks 5 questions per day (1700 average) - day 6
Eight super classic pointer interview questions (3000 words in detail)
微服务注册与发现
C # create self host webservice
MySQL advanced notes
Buuctf question brushing notes - [geek challenge 2019] easysql 1