-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Various cleanups: Use unnamed namespaces #4124
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
Various cleanups: Use unnamed namespaces #4124
Conversation
The `constexpr` variables and `static` functions had internal linkage, so this is unobservable to other TUs. We can drop `static` now.
UCRT `<new.h>` declares `_set_new_handler`, which is better than trying to declare it ourselves. We can then drop the `new_hand` typedef which was being used for that declaration. The `_New_handler` variable was `static`, so we can clearly move it into an unnamed namespace and drop the `static`. We do need to qualify the `_STD new_handler` type now. The `_New_handler_interface` helper function was never dllexported nor referred to by other stl/src TUs. We can move it out of `namespace std` and into the unnamed namespace. The resulting code has our desired distinction between TU-local and dllexported machinery.
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
|
I've resolved the simple merge conflict in |
|
|
||
| _CRTIMP2_PURE long long __cdecl _Xtime_get_ticks() { // get system time in 100-nanosecond intervals since the epoch | ||
| _CRTIMP2_PURE long long __cdecl _Xtime_get_ticks() noexcept { | ||
| // get system time in 100-nanosecond intervals since the epoch |
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.
It's been hard work causing all the merge conflicts on my own since @BillyONeal left the team.
(I recommend "ignore whitespace" while reviewing this.)
Over time, we've developed a convention of using unnamed namespaces in
stl/srcfor internal machinery. This clearly separates TU-local code from functions that are accessed from otherstl/srcTUs, injected into the import lib, or dllexported. I noticed a couple of older TUs that could benefit from being cleaned up.xtime.cpp: The_Epochand_Nsec100_per_secconstants can be function-local.xtime.cpp: Use an unnamed namespace, following our modern convention.constexprvariables andstaticfunctions had internal linkage, so this is unobservable to other TUs. We can dropstaticnow.stdhndlr.cpp: Use an unnamed namespace, following our modern convention.<new.h>declares_set_new_handler, which is better than trying to declare it ourselves. We can then drop thenew_handtypedef which was being used for that declaration._New_handlervariable wasstatic, so we can clearly move it into an unnamed namespace and drop thestatic. We do need to qualify the_STD new_handlertype now._New_handler_interfacehelper function was never dllexported nor referred to by otherstl/srcTUs. We can move it out ofnamespace stdand into the unnamed namespace.