当前位置:网站首页>Parameters in dynamic libraries cannot be modified through macro definitions or global variables in header files
Parameters in dynamic libraries cannot be modified through macro definitions or global variables in header files
2022-08-09 04:53:00 【little fly】
It is expected that the dynamic library provided to the user, through the macros or global variables defined in the header file of the library, modify the parameters used in the execution of logic in the dynamic library, and find that this path is not feasible. Once the dynamic library has been generated, modify the headerThe macro definitions or global variables in the file will not modify the variables in the dynamic library, and these variables still use the values defined when the dynamic library is generated.
Header file definition:
#pragma once#ifdef TESTLIBRARY_EXPORTS#define TESTLIBRARY_API __declspec(dllexport)#else#define TESTLIBRARY_API __declspec(dllimport)#endif#define TWO_CHANNEL_MAX_POWER_DIFF 0.5 // Two channel maximum average powerdifference// or using external variableextern twoChMaxPwrDiff = 0.5;
Once the dll is generated using the above header file, TWO_CHANNEL_MAX_POWER_DIFF
and twoChMaxPwrDiff
have been determined, this header file and dll are provided to the user, and the user modifies theMacro or global variable definitions will not take effect, and the values used are still those defined when the dll was generated.
The solution to this problem is to provide a new interface function, which the user calls to modify the parameters in the dll, which is the same logic as the way of passing parameters.
Header file
extern "C" TESTLIBRARY_API void __cdecl SetTwoChMaxPwrDiff(doublespan> diff);
Source file
static double twoChMaxPwrDiff = 0; //variable definitionspan>void SetTwoChMaxPwrDiff(double diff) {twoChMaxPwrDiff = diff;}
边栏推荐
- 【HMS core】【Ads Kit】Huawei Advertising——Overseas applications are tested in China. Official advertisements cannot be displayed
- 抖音直播间带货最新玩法和运营技巧
- 软件测试的方法详细介绍
- OKR management process, how to implement effective dialogue, using the CFR feedback and recognition?
- Pycharm社区版专业版下载安装环境配置【精细到每一个步骤】
- LeetCode - remove consecutive nodes with a sum of zero from a linked list
- 【HMS core】【ML kit】机器学习服务常见问题FAQ
- 抖音直播新号怎么起号?抖音直播间不进人怎么办?
- 2022 Security Officer-A Certificate Special Work Permit Exam Question Bank and Online Mock Exam
- "IP" command to configure network interface
猜你喜欢
在快手工作是一种什么体验
leetcode:402. 移掉 K 位数字
【HMS core】【ML kit】Machine Learning Service FAQ
leetcode:315. 计算右侧小于当前元素的个数
Alibaba Cloud Tianchi Contest Question (Machine Learning) - Repeat Purchase Prediction of Tmall Users (Complete Code)
学习笔记_numpy图片基本操作_自用
MySQL: Intent Shared Locks and Intentional Exclusive Locks | Deadlocks | Lock Optimization
Harmony OS ets ArkUI 】 【 】 development create a view and building layout
[OpenCV] - Find and draw contours
【Harmony OS】【ArkUI】ets开发 图形与动画绘制
随机推荐
杰理之SD卡切回蓝牙没有作用【篇】
I.MX6U-ALPHA开发板(串口实验)
【HMS Core】【FAQ】【AR Engine】AR Engine常见问题合集
杰理之播放最大音量提示音播不出来【篇】
Disappearance of heritability - wiki
php uses phpoffice/phpspreadsheet to import and export excel tables
I.MX6U-ALPHA开发板(高精度定时器)
B. Arrays Sum
Golang 常见知识点整理
JS-DOM-全局、局部、隐式变量,数组()\函数、 prompt输入对话框、confirm(确定用户的决定-弹出对话框)
LN论文、五种归一化原理和实现
Introduction to JVM garbage collection mechanism
匿名共享内存 ashmem
A case of missing heritability
Alibaba Cloud Tianchi Contest Question (Machine Learning) - Repeat Purchase Prediction of Tmall Users (Complete Code)
【HMS core】【ML kit】机器学习服务常见问题FAQ
perl基础语法归纳
全栈代码测试覆盖率及用例发现系统的建设和实践
leetcode:402. 移掉 K 位数字
Understanding ML Cross Validation Fast