当前位置:网站首页>Aardio - 不声明直接传float数值的方法
Aardio - 不声明直接传float数值的方法
2022-07-06 14:39:00 【卢光庆】
本文内容已整理到:
Aardio - API调用分析_卢光庆的博客-CSDN博客_aardio
因为个人觉得相关资料较少,特在此另发一文,以作参考。
因为aardio在不声明直接调用dll的时候,对于数值型参数是这样处理的:
数值参数一律处理为32位int整型。(小于32位的整数、枚举类型、8位或32位bool值都跟int 32位数值兼容)
所以,如果要传递float数据类型,如何传递呢?
这里写了两个dll函数进行测试:

aardio调用代码如下(测试过程就不详细解释了,直接说结果吧):
import console;
var dll=..raw.loadDll("\show.dll")
//传值测试:
//数值型数据结构
dll.show_byvalue(123.456)
//错误(float传递时被自动处理为整数类型,值已发生改变)
dll.show_byvalue(..raw.float(123.456))
//正确(构造为小数类型,aardio自动识别并在调用时自动调整参数类型为float)
//传址型数据结构
dll.show_byvalue({float v=123.456})
//错误(传的是“地址”,不是“数值”,值不一样)
dll.show_byvalue(..raw.float(123.456,true))
//错误(传的是“地址”,不是“数值”,值不一样)
//数值型,数据类型转换,将float数值转为int数值,再进行传递
dll.show_byvalue(raw.convert({ float f = 123.456 },{int i}).i)
//正确(用int数值,伪造float类型的内存数据,能被dll正确解析为float数值。原理同union)
//总之,就是必须将正确的“值”传递过去。
//传址测试:
//数值型数据结构
dll.show_byaddr(123.456)
//错误,地址非法,保护异常,程序退出
dll.show_byaddr(..raw.float(123.456))
//错误,地址非法,保护异常,程序退出
//传址型数据结构
dll.show_byaddr({float v=123.456})
//正确
dll.show_byaddr(..raw.float(123.456,true))
//正确
//传址相对比较简单,其他方法不一一测试了。
console.pause(true);
边栏推荐
- 2022年6月国产数据库大事记-墨天轮
- GPS from getting started to giving up (XI), differential GPS
- Kohana database
- Problems in the process of opencv300 cmake generating project
- Unity3d minigame unity webgl transform plug-in converts wechat games to use dlopen, you need to use embedded 's problem
- What are the interface tests? What are the general test points?
- Force buckle 575 Divide candy
- Embedded common computing artifact excel, welcome to recommend skills to keep the document constantly updated and provide convenience for others
- NetXpert XG2帮您解决“布线安装与维护”难题
- 硬件開發筆記(十): 硬件開發基本流程,制作一個USB轉RS232的模塊(九):創建CH340G/MAX232封裝庫sop-16並關聯原理圖元器件
猜你喜欢

GPS從入門到放弃(十三)、接收機自主完好性監測(RAIM)

剪映+json解析将视频中的声音转换成文本

Common sense: what is "preservation" in insurance?

Unity3d minigame unity webgl transform plug-in converts wechat games to use dlopen, you need to use embedded 's problem

Hardware development notes (10): basic process of hardware development, making a USB to RS232 module (9): create ch340g/max232 package library sop-16 and associate principle primitive devices

HDR image reconstruction from a single exposure using deep CNNs阅读札记
![[线性代数] 1.3 n阶行列式](/img/6e/54f3a994fc4c2c10c1036bee6715e8.gif)
[线性代数] 1.3 n阶行列式

基於 QEMUv8 搭建 OP-TEE 開發環境

二叉(搜索)树的最近公共祖先 ●●

0 basic learning C language - interrupt
随机推荐
在IPv6中 链路本地地址的优势
基於 QEMUv8 搭建 OP-TEE 開發環境
Shortcut keys in the terminal
GD32F4XX串口接收中断和闲时中断配置
Data storage (1)
Management background --5, sub classification
Spatial domain and frequency domain image compression of images
硬件開發筆記(十): 硬件開發基本流程,制作一個USB轉RS232的模塊(九):創建CH340G/MAX232封裝庫sop-16並關聯原理圖元器件
Mongodb (III) - CRUD
Adjustable DC power supply based on LM317
做接口测试都测什么?有哪些通用测试点?
Report on technological progress and development prospects of solid oxide fuel cells in China (2022 Edition)
C#实现水晶报表绑定数据并实现打印4-条形码
Notes de développement du matériel (10): flux de base du développement du matériel, fabrication d'un module USB à RS232 (9): création de la Bibliothèque d'emballage ch340g / max232 SOP - 16 et Associa
3DMax指定面贴图
LeetCode刷题(十一)——顺序刷题51至55
12、 Start process
Lora sync word settings
Set status bar style demo
Research and investment strategy report of China's VOCs catalyst industry (2022 Edition)