-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
permission: move PrintTree into unnamed namespace #48874
permission: move PrintTree into unnamed namespace #48874
Conversation
This function is not declared outside of fs_permission.cc and thus should not be visible outside the file during the linking stage.
Review requested:
|
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.
LGTM. Would you mind explaining the current problem? Just to not make the same mistake again
@RafaelGSS Of course :) When building a C++ application, each compilation unit (e.g., As a rule of thumb, the visibility of symbols during the compilation phase should match the visibility of symbols during the linking phase. In this case, for example, This can lead to subtle bugs. (I'll ignore name mangling in this section.)
Moving a function into an anonymous namespace within a compilation unit ensures that it will not be visible outside of the compilation unit during the linking phase. (In most cases, the same can be accomplished by marking the function as Properly managing visibility has other benefits, too. For example, you might want to get a compiler warning if a function is unused. However, if a function is not in an anonymous namespace and not marked as |
Thank you! |
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.
Thank you much for explaining so well @tniessen :-)
Landed in 88ab2e7 |
This function is not declared outside of fs_permission.cc and thus should not be visible outside the file during the linking stage. PR-URL: nodejs#48874 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
This function is not declared outside of fs_permission.cc and thus should not be visible outside the file during the linking stage. PR-URL: nodejs#48874 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
This function is not declared outside of fs_permission.cc and thus should not be visible outside the file during the linking stage. PR-URL: nodejs#48874 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
This function is not declared outside of fs_permission.cc and thus should not be visible outside the file during the linking stage. PR-URL: nodejs#48874 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
This function is not declared outside of fs_permission.cc and thus should not be visible outside the file during the linking stage. PR-URL: nodejs#48874 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
This function is not declared outside of fs_permission.cc and thus should not be visible outside the file during the linking stage. PR-URL: nodejs#48874 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
This function is not declared outside of fs_permission.cc and thus should not be visible outside the file during the linking stage. PR-URL: #48874 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
This function is not declared outside of
fs_permission.cc
and thus should not be visible outside the file during the linking stage.