-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Drop z_ prefix as identifier for internal/private functions and revert back to _ #58007
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
Comments
Just a heads up (and I know this isn't a link to the ISO C standard), but there are some related rules for prefixing symbols with an underscore. I have not looked (at least recently) to verify / locate where they are in the ISO C standard. https://stackoverflow.com/a/39625502
It's possible that the double underscore point might have some flexibility because typically those are reserved by the "system" which would very much include Zephyr. However, single underscore followed by a capital letter could very well result in a number of collisions (e.g. POSIX feature test macros). I'm not entirely sure if there are other standard names of the form |
I never liked z_ and think this would be nicer. Double or single underscore doesn't matter much to me. But I do point out that I really (really) hate the churn from treewide syntax changes like this and think we should implement some kind of blood oath to be taken by all involved to ensure this is the last time we're going to do this. |
Apart from what @cfriedt already pointed out ( |
Would this be a new policy going forward or do you intend to change existing code? |
An approach I used in other projects in the past is the one from ie, public functions look like |
My 2 cents:
My take would be to either not mess around with the
I fully agree. An olden link: |
great input, I am well aware of all those constraints and issue with standards, but the current situation is bad enough IMO and this z_ prefix is very confusing and I have seen private functions being used as if they were public APIs. Most notable example is https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/sys/fdtable.h, where some has decided to use z_ as the preferred prefix for zephyr public APIs... |
As a user, I'd say I haven't hit a ton of confusion understanding that |
If there is going to be a change, why make a change that is going to actively impact the efforts of multiple other individuals/teams working on enabling Zephyr for passing industry safety standards? As @andyross points out, there is likely one last chance (before end users and developers revolt) to make this type of change again. If this is going to change, picking something more clear |
I've been doing this in a couple of places already, but for reserved, internal Zephyr API, I believe the |
Have we decided which direction we are going ? @aescolar made good points. We have being fixing some symbols collision in an ad-hoc way, here is one more #78906 needed. I honestly don't think we can take the approach that we are the OS and others should adapt to that. It seems to me that we need a proper namespace for pretty much everything. |
Just wanted to follow-up - my
I think |
Architecture WG: Options:
|
I'd just forget about the |
Architecture WG:
|
Architecture WG:
|
I think I mentioned this in some past meeting, and someone had a counterargument, which I forgot, so I'll repeat it: what we essentially have is the desire to represent two independent attributes of an API through some naming convention:
There seems to be a consensus that the the naming convention should be based on prefixes, however I don't see it as self-evident that the order of these prefixes should be "public/private first, subsystem second". E.g. I could perfectly well imagine using |
Introduction
Revert back to old naming conventions and use _ for private functions and drop the usage of z_ as a prefix in zephyr completely.
Problem description
The z_ as prefix for internal/private functions is misleading and giving the impression functions with z_ are public APIs.
The use of z_ was introduced to deal with some coding guideline violations. The project has since decided to not follow this rule and it is not part of the coding guidelines right now (need to check).
Proposed change
Go back to _ (underscore) as an identifier for private functions and remove all usage of z_ in zephyr.
Detailed RFC
This is going to be a treewide change that will clarify zephyr APIs and avoid any confusion about what functions should be used out of tree. This is not going to be an API change per se, it will however cause some issues with users depending on internal functions out of tree.
The scope of private functions should also be clarified as part of this RFC and if we should allow usage of internal/private calls across the tree, i.e. subsystem A calls private functions for subsystem B.
Concerns and Unresolved Questions
Major change that needs lots of preparating and discussions.
Alternatives
document clearly the z_ prefix and do not allow exporting functions with z_ in public APIs.
The text was updated successfully, but these errors were encountered: