Calculator: Adopt C++ standard types across codebase

Created on 27 Feb 2019  路  3Comments  路  Source: microsoft/calculator

Calculator currently uses windows-specific types in some places, such as UINT. We should adopt the C++ standard types in their place.

2 approved codebase quality help wanted

Most helpful comment

How "standards compliant/cross compiler compatible" does this issue want to go? My understanding that the best way to work across multiple compilers is to not only include the <cstdint> header but also access these types through the std namespace. Code such as the following doesn't do either, but it is technically using the C++ standard typedefs.
https://github.com/Microsoft/calculator/blob/6a1c2e4bbfd81a9018c8b3e39d2d4afef5caf9f2/src/CalcManager/Header%20Files/Number.h#L14

All 3 comments

This is your friendly Microsoft Issue Bot. I created this issue automatically as requested by a team member.

How "standards compliant/cross compiler compatible" does this issue want to go? My understanding that the best way to work across multiple compilers is to not only include the <cstdint> header but also access these types through the std namespace. Code such as the following doesn't do either, but it is technically using the C++ standard typedefs.
https://github.com/Microsoft/calculator/blob/6a1c2e4bbfd81a9018c8b3e39d2d4afef5caf9f2/src/CalcManager/Header%20Files/Number.h#L14

What the standard has to say about this...

C++11 (taken from the n3242 draft):

Except as noted in Clauses 18 through 30 and Annex D, the contents of each header cname shall be the same as that of the corresponding header name.h, as specified in the C standard library (1.2) or the C Unicode TR, as appropriate, as if by inclusion. In the C++ standard library, however, the declarations (except for names which are defined as macros in C) are within namespace scope (3.3.6) of the namespace std. It is unspecified whether these names are first declared within the global namespace scope and are then injected into namespace std by explicit using-declarations (7.3.3).

The C++17 version is pretty much the same, but with updated section, clause and annex numbers/identifiers.

The most important point to take away from this is that "the declarations ... are within namespace scope of the namespace std.".
The standard only specifies that the names must be in the namespace std,
it does not explicitly specify that they should also be in the global namespace.

Furthermore, the "Header synopsis" ([cstdint.syn]) provided by the standard also only specifies the types in the std namespace.
(The only difference between the C++11 and C++17 listing is that C++11 uses typedef and C++17 uses using.)

Was this page helpful?
0 / 5 - 0 ratings