Replace custom types with standard ones#212
Replace custom types with standard ones#212danbelcher-MSFT merged 17 commits intomicrosoft:masterfrom
Conversation
|
Given warm feedback in #109 (comment) I want to continue working on that, but would appreciate some guidance from Microsoft team of you intend to merge such PR. I would also appreciate feedback on how would you like to approach this in context of #211. My idea for that would be merge #212 (this) first, then rebase #211 on top, so there's no need for |
|
This is great. The more standard types we can use, the better. |
|
You replaced all the names, including those in comments, including those reflecting the type's intention. For example, the code is messed up because all Please bear in mind that you're not just coding in C++. You're coding in C++ with Win32 conventions, where Other than those, I do find some methods, e.g., |
|
I'm aware of the comments issue, I labeled the commit incomplete for that reason, as well as explained that in opening comment. Win32 should not matter in the core/engine part of a calculator. The intent of this PR is to not introduce behaviour changes, so any changes you suggest should be done in a separate one. |
@fwcd, how do you feel about @janisozaur's suggestion for merging both changes? It'll give each of you an opportunity to contribute. It seems like we should wait to merge until we have CI builds running with Clang so we don't regress later. |
|
I plan to resume work on it this weekend, maybe a bit earlier. |
|
@danbelcher-MSFT That sounds good. |
1ad801f to
4a92e92
Compare
|
I have rebased this now, but it's not fully done yet. |
57e40fb to
3c0054c
Compare
|
I've implemented all the things I wanted for this PR. Here's a brief summary:
With these changes I can successfully compile the code with GCC and clang (though only with libc++, see #321), the test suite also seems to be passing on Azure. There are 16 commits in total for now, please let me know if you would like them rebased any other way.
My (obviously biased) advice is to not block this on having CI builds with clang, this is something that would be easier to restore if regressed than having to start over because of conflicts, etc. I've already left some comments on #211, there are still ones that need to be addressed. Once #212 (this) gets merged I'd expect @fwcd to update #211, which I will review for the final time and it could be merged. I have little experience with Azure Pipelines, but will start looking into ways clang and GCC can be tested so it doesn't regress. I hope to come up with something within a week or two, if someone doesn't beat me to it. @danbelcher-MSFT @fwcd does that sound like a possible way forward? I'd appreciate quick feedback, I will try to address it as soon as I can, so this PR doesn't get stale by other changes. |
|
@danbelcher-MSFT @HowardWolosky is there anything here you still want changed? |
|
Like @GeeLaw, I have concerns about if the updated types reflect the correct use of that data. For example, now there is code such as Is there a middleground approach? Something along the lines of: #ifndef HRESULT
#define HRESULT int32_t
#endifOr is this a no-go? |
|
I see your point. How about I will typedef the replacements where I deem applicable ( Feel free to provide suggestions on how the names should map.
This is what original code did. Perhaps that was not intentional, as was pointed out by @GeeLaw's comment:
Still, I'd rather typedef it to Can you address other points I raised in #212 (comment)? |
Sounds good to me! Definitely in support here.
Great, I think that's a perfectly valid change to make.
Absolutely, this is an improvement we should all be in favor of.
That's fair. For my previous comment, I'm not necessarily asking for any change here at all, just pointing out that we should be concerned about the semantics of the types we're using and asking you to take care in your changes to make sure the code is still readable and reflects intent. For cases like
Sure. Sorry for the delay.
Thank you! for going through the effort of finding an appropriate replacement. The parts of the code that use this are all concerned with manual management of memory. I do wonder if the better change here is to replace with std C++ functionality, so we're safer and more portable.
Yep, this bugs me too. Let's disable the macros.
Okay, to recap, we're merging #212 (this) first, then #211 after. With 211, I had wanted to install Clang myself and try out the changes, but I haven't had time yet. We'll go ahead with merging those without CI support, which will be added at a later date. The community will need to help out by raising an issue if the build regresses, until we can stand up the new environment in our CI build. Side note, if you have simple setup instructions for an engineer who has only developed with MSVC, I would be happy for the help :) Maybe this is something that should be added as documentation to help cross-pollinate developers coming from different platforms? Did that address all your questions or was there something else? |
5f94854 to
482146e
Compare
|
I changed
Can you submit PR for that? |
482146e to
ce42185
Compare
|
This should have all the latest feedback incorporated. Let me know if there's anything more that requires updating.
There are a few ways you can try.
I think I would recommend MSYS2 (or its sibling nuwen), if you want to keep it relatively lightweight. Otherwise, consider WSL. To first configure with CMake, you would do |
The source is under MIT license
Additionally the one or two instances of "*longlong" to "*i64"
9d5b032 to
69d8b38
Compare
|
This is now updated with all the points addressed, CI is green too. |
|
@janisozaur, thanks for this change! Thank you also for the instructions you provided above. I'll try to get set up and we can work on getting the Clang support checked-in as well. |
|
Looks like this regressed our ARM and ARM64 builds: https://dev.azure.com/ms/calculator/_build/results?buildId=7838 @janisozaur, can you help investigate? |
|
Sure, on it. |
| // This format is based loosely on an OLE HRESULT and is compatible with the | ||
| // SUCCEEDED and FAILED macros as well as the HRESULT_CODE macro | ||
|
|
||
| typedef int32_t ResultCode; |
There was a problem hiding this comment.
If you're gonna dump HRESULTs, you might as well keep the annotations by using something like _Return_type_success_(return >= 0).
There was a problem hiding this comment.
This would, however, re-introduce non-standard extensions and thus break platform-independence.
Fixes ARM(64) regression introduced with #212
I was halfway through changing the types, when #211 was submitted. As I have ran out of time today to finish it up, I submit it as-is for discussion and would like to hear from Microsoft team on which approach is preferred.