当前位置:网站首页>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】【ML kit】机器学习服务常见问题FAQ

MySQL: Implementation Principles of Submitted Read and Repeatable Read | MVCC (Multi-Version Concurrency Control) - Notes for Your Own Use

存储系统架构演变

2022年8月深圳产品经理认证招生简章(NPDP)

抖音直播新号怎么起号?抖音直播间不进人怎么办?

The influence law of genes for disease - read the paper

equals和==

杰理之一拖二 另一台手机超距 通话会无声【篇】
![[OpenCV] - Find and draw contours](/img/05/4f877bb779d7e5ffa71ed1fc55ba63.png)
[OpenCV] - Find and draw contours

Quantitative Genetics Heritability Calculation 1: Parent-Child Regression Method
随机推荐
杰理之手机OTG问题【篇】
Alibaba Cloud Tianchi Contest Question (Machine Learning) - Repeat Purchase Prediction of Tmall Users (Complete Code)
【Harmony OS】【ArkUI】ets开发 基础页面布局与数据连接
安装pytorch和cuda
【Harmony OS】【ARK UI】Public Event Module
亚马逊面对风控,自养号测评时应该怎么做?
equals和==
Introduction to JVM garbage collection mechanism
【HMS core】【Ads Kit】Huawei Advertising——Overseas applications are tested in China. Official advertisements cannot be displayed
供应商对接Chewy的EDI需求
How to trim svg and compress
equals and ==
2022下半年深圳信息系统项目管理师认证招生简章
AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline'
The influence law of genes for disease - read the paper
杰理之播歌曲前后音量大小不一样【篇】
【HMS Core】【FAQ】【AR Engine】AR Engine FAQ
[MLT] Analysis of MLT Multimedia Framework Production and Consumption Architecture (2)
【ITRA】2022年ITRA赛事注册流程 从0-1
2022-08-08 mysql慢SQL-Q18-10GB数据量-mysql/innodb测试