-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[kernel]add a macro RT_VERSION_CHECK #5850
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
名字不太好,这个的作用更像是计算/生成一个数字,而不是检查
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果要是有检查 warning error的功能就更好了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
什么 waring error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
就是定义一个宏定义,在文件底部或者文件的顶部,设置改文件最低允许的版本号,如果低于该版本号就会给出error或者waning,提示需要提升软件包版本或者降低内核版本。
我只是异想天开,仅供参考。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
放文件开头,就这样用
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
仔细看它这个实现,看例子挺清爽,但是不仔细看实现,也不知道这个宏实现功能是啥,而且只实现了 >= 的逻辑运算。这样使用的时候也挺受限制的。
所以,lvgl 源码里搜索一下,发现大量下面用法
”LV_VERSION_CHECK“对“非 6.0 版本” 这种情况表达无力,只能用 LVGL_VERSION_MAJOR LVGL_VERSION_MINOR 挨个比较。
还有
我没理解错的话,LV_VERSION_CHECK(7, 4, 0) 的意思就是 “大于等于 7.4.0 或者 7.4.0 以后的版本“。后面又混用了个 ”LVGL_VERSION_MAJOR >= 8“ 不知道当初改这行代码的人啥想法。
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LV_VERSION_CHECK 的宏挺严谨的,里面包含了这三个版本值的 API 变更逻辑的。首先主版本号必须相同,然后,后面的版本号的变化 API 都是向前兼容的。所以这里才单独判断了下 || LVGL_VERSION_MAJOR >= 8
这里LV_VERSION_CHECK宏的名字就代表了他的功能,会把检查的逻辑写在宏内部。如果我们起名也要有check的话,就应该把check的逻辑实现在宏的内部。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多定义一个宏,就是减少 MAJOR MINOR 几个宏的使用
这样混用只能说明那个 LV_VERSION_CHECK 定义的不足。这样混合使用还不如全用 MAJOR MINOR 几个判断来的清晰
不是说 LV_VERSION_CHECK 这样定义,RT_VERSION_CHECK 的含义就必须跟它是一样的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
最近有新的想法吗,希望在4.1.1上能把这个版本检查的功能合进去。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
过了段时间,我忽然感觉这种方式挺好的,如果只是站在使用者角度看,使用方法又灵活,又清晰。就是内部实现有点让人迷惑。如果没有更好的想法,这种方式我也可以接受