-minstd: Require a minimum std version, without being specific
Alejandro Colomar
alx.manpages@gmail.com
Wed Dec 21 18:33:48 GMT 2022
Hi,
I've long had this wish: an option similar to -std, but which would not specify
the standard. Rather, mark a requirement that the standard be at least a version.
This would be especially useful for libraries, which might for example require
C99 or C11 to work. They would be able to specify -minstd=c11 in their pc(5)
file (for use with pkgconf(1)). That way, a program using such library, would
be free to use -std to specify the C version that the project should be compiled
with; maybe gnu17, maybe even gnu2x. But if the program tries to compile under,
say gnu89, the compiler would report an error.
If the option is repeated, the requirement will be the higher of all of them,
using the following rules:
- If no -minstd invocations mention gnu, -std may specify either ISO C or GNU
C. If any -minstd invocations mention gnu, -std can only specify GNU C.
- -std may only specify a language version at least as high as the highest
version specified by -minstd invocations (ignoring the dialect, that is GNU or
ISO C).
Examples:
-minstd=c99 -minstd=gnu89
This would be equivalent to -minstd=gnu99
The default of -std=gnu17 would apply.
-minstd=c89 -minstd=c99
This would be equivalent to -minstd=c99
The default of -std=gnu17 would apply.
-minstd=gnu2x
The default of -std=gnu17 would not be enough;
Compilation error.
-minstd=gnu99 -std=c99
C99 is "less" than the required GNU C99.
Compilation error.
It could also be used by programs, to specify a minimum C version that it
supports, while not preventing newer compilers from using newer versions. It
would only tell users when they try to compile in old systems that their system
is not supported.
It is different from -std, because -std is more useful to lock a maximum version
that is supported, rather than a minimum. -std is normally used by projects
that don't support recent versions of C, to force compilation with old versions.
Does it make sense to you?
Cheers,
Alex
--
<http://www.alejandro-colomar.es/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20221221/57442a10/attachment.sig>
More information about the Gcc
mailing list