|
|
Subscribe / Log in / New account

New C features in GCC 13 (Red Hat Developer)

New C features in GCC 13 (Red Hat Developer)

Posted May 5, 2023 0:56 UTC (Fri) by branden (guest, #7029)
In reply to: New C features in GCC 13 (Red Hat Developer) by ceplm
Parent article: New C features in GCC 13 (Red Hat Developer)

Explicit is better than implicit.

With a plain "int" you get an integer of whatever size the platform feels like providing. Is it a fast int? Is it a small int? Undefined.


to post comments

New C features in GCC 13 (Red Hat Developer)

Posted May 5, 2023 6:56 UTC (Fri) by mb (subscriber, #50428) [Link] (7 responses)

It's certainly not undefined.
And the fast/least types are BS. Sprinkling the code with ugly fast-types doesn't make it any faster. It just increases the likelihood of subtle bugs due to actual type size differences between platforms.
Just use fixed types like uint32_t.

New C features in GCC 13 (Red Hat Developer)

Posted May 5, 2023 9:35 UTC (Fri) by ballombe (subscriber, #9523) [Link] (5 responses)

Except there is no libc support for it (no int32abs() , no support in printf etc.) so it is difficult to use correctly.

New C features in GCC 13 (Red Hat Developer)

Posted May 5, 2023 10:03 UTC (Fri) by adobriyan (subscriber, #30858) [Link] (1 responses)

printf support exists with PRIu32 macros etc

New C features in GCC 13 (Red Hat Developer)

Posted May 5, 2023 22:40 UTC (Fri) by bartoc (guest, #124262) [Link]

I _think_ c23 actually added support for them to printf, without the horrible PRI macros.

New C features in GCC 13 (Red Hat Developer)

Posted May 5, 2023 10:05 UTC (Fri) by hkario (subscriber, #94864) [Link]

there is support for uint32_t in both printf and sscanf, it's just fugly

New C features in GCC 13 (Red Hat Developer)

Posted May 5, 2023 12:57 UTC (Fri) by HenrikH (subscriber, #31152) [Link] (1 responses)

there are imaxabs() in libc since C99 that can handle every single integer size

New C features in GCC 13 (Red Hat Developer)

Posted May 5, 2023 15:19 UTC (Fri) by magfr (subscriber, #16052) [Link]

Except those it can't handle.
intmax_t tend to get frozen when ABIs are set and afterwards they wont change even if the compiler supports wider types.

GCC on x86_64 have supported _int128 for years but glibc have not.

New C features in GCC 13 (Red Hat Developer)

Posted May 10, 2023 0:36 UTC (Wed) by DemiMarie (subscriber, #164188) [Link]

Some embedded platforms do not define all of the fixed-size integer types! For instance, some DSPs cannot access individual bytes, so char is 16 bits and uint8_t doesn’t exist. int_least8_t could be useful for documentation there.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds