Sad that C23 didn't get symbol visibility attributes. They are very useful for libraries. Perhaps there is still a chance to get them?
I suppose because they are an ELF feature rather than a language feature? Anyway you can (and should!) use -fvisibility=hidden and add __attribute__((__visibility__("default"))) to public symbols when writing a C library. It will make calls between non-visible symbols faster because the compiler doesn't have to generate code to handle ELF symbol interposition.
C23 Implications for C Libraries
31–40 of 135 posts
Re: C23 Implications for C Libraries
#32"Extended integer types may be wider than intmax_t". I'm sure there's a good reason for this, but it was introduced in C99, which says (in 7.8.1.5): "[intmax_t] designates a signed integer type capable of representing any value of any signed integer type". That was already portable between 16 bit, 32 bit, 64 bit etc. Why is it that just because the compiler supports 128 bit or 256 bit integers that compiling in such…
Presumably because the size of intmax_t was set to something specific on its introduction and changing it now would constitute an ABI break most everywhere.
And now code written to conform with the intent and wording of C99 will need to change?
Re: C23 Implications for C Libraries
#33Earlier quoted context omitted.
I suppose because they are an ELF feature rather than a language feature? Anyway you can (and should!) use -fvisibility=hidden and add __attribute__((__visibility__("default"))) to public symbols when writing a C library. It will make calls between non-visible symbols faster because the compiler doesn't have to generate code to handle ELF symbol interposition.
These are non-standard GNU extensions, unfortunately.
That said, there are effectively two standard compiler interfaces: MSVC and GCC and everyone else emulates one or both of these.
Similarily, symbol visibility is not something that the C standard cares about because it doesn't even care about libraries in the first place. Again, for all platforms that have symbol visibility (e.g. PE and ELF based ones, although the details differ) there is a defacto standard for the compiler flags and attributes to control the visilibity: the MSVC and GCC extensions.
Re: C23 Implications for C Libraries
#34The page gives a network error. Edit: Ugh, it needs javascript to render simple HTML.
Re: C23 Implications for C Libraries
#35Earlier quoted context omitted.
That’s exactly right. On platforms without ABI stability concerns, there’s no issue, but if you can’t change the ABI intmax_t is stuck being what it’s always been (which is why it was always obviously a bad idea and should not have been included in the standard).
No problem, just introduce intreallymax_t and later intmaxthistimewereallymeanit_t.
Re: C23 Implications for C Libraries
#36Earlier quoted context omitted.
In C23, `bool`, `true` and `false` are available without including `stdbool.h`.
Great news! \o/
Re: C23 Implications for C Libraries
#37Re: C23 Implications for C Libraries
#38Earlier quoted context omitted.
These are non-standard GNU extensions, unfortunately.
All compiler flags are non-standard because the C standard does not concern itself with them at all. That said, there are effectively two standard compiler interfaces: MSVC and GCC and everyone else emulates one or both of these. Similarily, symbol visibility is not something that the C standard cares about because it doesn't even care about libraries in the first place. Again, for all platforms that have symbol visi…
Re: C23 Implications for C Libraries
#39Earlier quoted context omitted.
No problem, just introduce intreallymax_t and later intmaxthistimewereallymeanit_t.
int -> intpro_t -> intmax_t -> intultra_t
Re: C23 Implications for C Libraries
#40Earlier quoted context omitted.
Presumably because the size of intmax_t was set to something specific on its introduction and changing it now would constitute an ABI break most everywhere.
So, a "what your mother didn't tell you about C standardization!". I.e. that some popular compilers flaunted the standard, as wider and supported integers should surely have been "[u]intmax_t". And now code written to conform with the intent and wording of C99 will need to change?
If you have an interface that has a function that e.g. takes an intmax_t parameter (and even the C standard has those, e.g. imaxabs()), increasing intmax_t size (ABI change) would break existing callers.
So you can only change intmax_t size if you do not care about ABI stability.