-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Changed macro constants to constexpr variables #270 #487
Changed macro constants to constexpr variables #270 #487
Conversation
This reverts commit 7e5b7b3.
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.
Perhaps we should make them less SHOUTY given that they're no longer macros?
hmm yeah I've been think about that too. |
Existing stuff seems to be |
Correct, it would have to be |
oh okay :) I see , let me apply that then |
Co-Authored-By: Casey Carter <cartec69@gmail.com>
are unused, there is some reason to keep them in the file ? |
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.
This looks good. I observe that there are several more files with macro constants that could be cleaned up (found by regex-searching for #define \w+\s+\w+
within stl/src/*.cpp
in VSCode):
Lines 29 to 33 in 30031d3
// Pre-V4 managed exception code | |
#define MANAGED_EXCEPTION_CODE 0XE0434F4D | |
// V4 and later managed exception code | |
#define MANAGED_EXCEPTION_CODE_V4 0XE0434352 |
Lines 270 to 272 in 30031d3
#define WIN_TICKS_PER_SECOND 10000000ULL | |
#define WIN_TICKS_FROM_EPOCH (((1970 - 1601) * 365 + 3 * 24 + 17) * 86400ULL * WIN_TICKS_PER_SECOND) |
Line 10 in 30031d3
#define NSTDSTR 8 // cin, wcin, cout, wcout, cerr, wcerr, clog, wclog |
Line 33 in 30031d3
#define NATS 10 // fclose, xgetloc, locks, facet free, etc. |
Line 14 in 30031d3
#define MAX_LOCK 8 // must be power of two |
Line 12 in 30031d3
#define NITEMS 20 |
Lines 13 to 15 in 30031d3
#define BASE 10 // decimal | |
#define NDIG 9 // decimal digits per long word | |
#define MAXSIG (5 * NDIG) // maximum significant digits to keep |
Line 17 in 30031d3
#define BASE_MAX 36 // largest valid base |
Line 17 in 30031d3
#define BASE_MAX 36 // largest valid base |
Lines 14 to 16 in 30031d3
#define BASE 16 // hexadecimal | |
#define NDIG 7 // hexadecimal digits per long element | |
#define MAXSIG (5 * NDIG) // maximum significant digits to keep |
Lines 13 to 15 in 30031d3
#define BASE 10 // decimal | |
#define NDIG 9 // decimal digits per long element | |
#define MAXSIG (5 * NDIG) // maximum significant digits to keep |
Lines 14 to 16 in 30031d3
#define BASE 16 // hexadecimal | |
#define NDIG 7 // hexadecimal digits per long element | |
#define MAXSIG (5 * NDIG) // maximum significant digits to keep |
After rereading #270, I realize that I had quoted xtime.cpp
intending it to be a non-exhaustive example of the files that needed to be cleaned up, but I didn't actually say that many files were affected. Oops!
If you'd like us to merge this PR as-is, we can certainly do so, and keep #270 open. If you want to extend these changes to more files, we can continue reviewing this PR. Just let us know! :-)
Great catch! If they're unused, they should definitely be eliminated. (We've changed this file over many years, so it's possible they were used at some point, and we missed these bits.) |
I think we should leave the ones in here alone because that constant needs to match how that's declared in CLR headers. |
Oh so, we can continue reviewing this PR, I'll extend these changes to more files. |
perfect, so I'll remove them |
Given @BillyONeal's explanation, I agree that leaving |
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.
Looks good, just found some parentheses that are no longer needed 🎉
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.
Looks great - I’ll port this to the Microsoft-internal repo and run a build and test pass. (We’re looking forward to when we finish migrating the build and tests to GitHub 😹)
Awesome !!! it's a pleasure for me ! =D |
While double-checking the Microsoft-internal port, I noticed a few more comments that needed to be updated. I think I found them all, so I went ahead and pushed a change to your branch. Running the build and tests now. (To find the comments, I used |
Thanks for modernizing this code! |
Description
Checklist
Be sure you've read README.md and understand the scope of this repo.
If you're unsure about a box, leave it unchecked. A maintainer will help you.
_Ugly
as perhttps://eel.is/c++draft/lex.name#3.1 or there are no product code changes.
verified by an STL maintainer before automated testing is enabled on GitHub,
leave this unchecked for initial submission).
members, adding virtual functions, changing whether a type is an aggregate
or trivially copyable, etc.).
the C++ Working Draft (including any cited standards), other WG21 papers
(excluding reference implementations outside of proposed standard wording),
and LWG issues as reference material. If they were derived from a project
that's already listed in NOTICE.txt, that's fine, but please mention it.
If they were derived from any other project (including Boost and libc++,
which are not yet listed in NOTICE.txt), you must mention it here,
so we can determine whether the license is compatible and what else needs
to be done.