public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: gcc@gcc.gnu.org
Cc: Andrew Clayton <andrew@digital-domain.net>
Subject: -minstd: Require a minimum std version, without being specific
Date: Wed, 21 Dec 2022 19:33:48 +0100	[thread overview]
Message-ID: <c9a8b74b-59a1-c960-0146-a115dba9456c@gmail.com> (raw)


[-- 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 --]

             reply	other threads:[~2022-12-21 18:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-21 18:33 Alejandro Colomar [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c9a8b74b-59a1-c960-0146-a115dba9456c@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=andrew@digital-domain.net \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).