Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

软件包不同版本的适配说明 #1774

Open
kurisaW opened this issue Sep 6, 2024 · 0 comments
Open

软件包不同版本的适配说明 #1774

kurisaW opened this issue Sep 6, 2024 · 0 comments

Comments

@kurisaW
Copy link
Contributor

kurisaW commented Sep 6, 2024

由于不同主线版本不可避免会修改某些函数声明或数据类型,因此对应的软件包也需要尽可能同步适配,通过版本宏去做区分,下面是一个示例

如:
1.在主线版本5.0.2中,分离sensor框架为V1和V2两个版本
image
2.在主线版本5.1.0中,修改fetch_data函数声明为:

rt_ssize_t (*fetch_data)(struct rt_sensor_device *sensor, void *buf, rt_size_t len);

相关PR:

参考修改方式如下:

#include <rtthread.h>
#include <rtdevice.h>

#if defined(RT_VERSION_CHECK)
    #if (RTTHREAD_VERSION >= RT_VERSION_CHECK(5, 0, 2))
        #define RT_SIZE_TYPE   rt_ssize_t
    #else
        #define RT_SIZE_TYPE   rt_size_t
    #endif
#endif

ps:原本对于sensor软件包需要包含头文件sensor.h或sensor_v2.h,我们替换为#include <rtdevice.h>,在该头文件中,会根据宏开关包含对应的头文件,如下图:

image

参考PR:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant