当前位置:网站首页>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.
边栏推荐
- Web security SQL injection vulnerability (1)
- Descriptor implements ORM model
- How does yyds dry inventory deal with repeated messages in the consumption process?
- Overview of OCR character recognition methods
- Eight super classic pointer interview questions (3000 words in detail)
- 2.12 simulation
- Pat 1046 shortest distance (20 points) simulation
- 下一个行业风口:NFT 数字藏品,是机遇还是泡沫?
- Prototype design
- Add one to non negative integers in the array
猜你喜欢
ERA5再分析资料下载攻略
XSS challenges bypass the protection strategy for XSS injection
2022工作中遇到的问题四
How to choose PLC and MCU?
Solve 9 with C language × 9 Sudoku (personal test available) (thinking analysis)
【RISC-V】外部中断
Maturity of master data management (MDM)
JS regular filtering and adding image prefixes in rich text
NR modulation 1
【若依(ruoyi)】设置主题样式
随机推荐
Differences and application scenarios between resulttype and resultmap
Self made CA certificate and SSL certificate using OpenSSL
Distributed service framework dobbo
[padding] an error is reported in the prediction after loading the model weight attributeerror: 'model' object has no attribute '_ place‘
My C language learning records (blue bridge) -- files and file input and output
What are the principles of software design (OCP)
故障分析 | MySQL 耗尽主机内存一例分析
Taobao focus map layout practice
CobaltStrike-4.4-K8修改版安装使用教程
Maturity of master data management (MDM)
Linear programming matlab
resulttype和resultmap的区别和应用场景
Master data management theory and Practice
C # create self host webservice
Arabellacpc 2019 (supplementary question)
Mysql database operation
适合程序员学习的国外网站推荐
【若依(ruoyi)】ztree 自定义图标(iconSkin 属性)
2.13 simulation summary
Leetcode problem solving -- 98 Validate binary search tree