public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* -minstd: Require a minimum std version, without being specific
@ 2022-12-21 18:33 Alejandro Colomar
  2022-12-21 18:51 ` Alexander Monakov
  2022-12-22  2:42 ` Ben Boeckel
  0 siblings, 2 replies; 8+ messages in thread
From: Alejandro Colomar @ 2022-12-21 18:33 UTC (permalink / raw)
  To: gcc; +Cc: Andrew Clayton


[-- Attachment #1.1: Type: text/plain, Size: 2087 bytes --]

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/>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-12-22  2:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-21 18:33 -minstd: Require a minimum std version, without being specific Alejandro Colomar
2022-12-21 18:51 ` Alexander Monakov
2022-12-21 18:53   ` Alejandro Colomar
2022-12-21 19:08     ` Alejandro Colomar
2022-12-21 19:14       ` Jonathan Wakely
2022-12-21 19:12     ` Alexander Monakov
2022-12-21 19:15       ` Alejandro Colomar
2022-12-22  2:42 ` Ben Boeckel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).