Allow (u) int_fastX_t at compile time

Implementations of the standard C ++ type typedef (u) int_fastX as one of their built-in types. This requires studies in which the type is the fastest, but for each case there cannot be one fastest type.

Wouldn't that increase performance to allow such types at compile time to take into account the case by choosing the optimal type for actual use? The compiler will analyze the use of the _fast variable and then select the optimal type. Factors entering the game may be the alignment and type of operations used with the variable.

This will make these types a language function.

This can lead to errors when the compiler suddenly decides to choose a different width for such a variable. But in such use cases, you should not use the _fast type, where the behavior depends on the width, in any case.

Is such compile-time resolution a permitted standard? If so, why is this not implemented today? If not, then why is this not a standard?

+4
source share
1 answer

No, this is prohibited by the standard. Keep in mind that the C ++ standard sends to C for this particular area, for example, C ++ 11 backs down to C99, according to C++11 1.1 /2. In particular, C++11 18.4.1 Header <cstdint> synopsis /2indicates:

The header defines all functions, types, and macros in the same way as 7.18 in the C standard.

So, letโ€™s understand your first contradiction, you declare:

++ typedef (u) int_fastX . , , .

C , c99 7.18.1.3 Fastest minimum-width integer types ( ):

, , , , .

; , , .

, , , , , , .

( ), , int .

, , , .

( ):


(1) ?

. C :

, <stdint.h> typedef .

, -, , typedef , "" typedefs, .

, typedef, (. ).

, , , , . 16- 32- .


(2) , ?

"" , , (, , , , ).


(3) , ?

- , . , , , ( ), .

, ++ ++, , , : -)

+1

Source: https://habr.com/ru/post/1666890/


All Articles