public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ben Boeckel <ben.boeckel@kitware.com>
To: Alejandro Colomar <alx.manpages@gmail.com>
Cc: gcc@gcc.gnu.org, Andrew Clayton <andrew@digital-domain.net>
Subject: Re: -minstd: Require a minimum std version, without being specific
Date: Wed, 21 Dec 2022 21:42:54 -0500	[thread overview]
Message-ID: <Y6PELi32YhG/VKvV@farprobe> (raw)
In-Reply-To: <c9a8b74b-59a1-c960-0146-a115dba9456c@gmail.com>

On Wed, Dec 21, 2022 at 19:33:48 +0100, Alejandro Colomar via Gcc wrote:
> 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.

(FD: CMake developer, ISO C++ SG15 committee member)

I'd like to see us move away from "flag soup" and instead towards more
structured information here. This request corresponds to CMake's
`C_STANDARD` target property[1] which CMake then puts together to mean
something.

Note that there are real hazards with just putting the flags like this
into `.pc` files directly. If you have a C library and say "-minstd=c99"
and I'm C++, what is supposed to happen with this flag for a C++
compilre? Does it translate to C++11 (which is the first C++ standard to
"fully contain" C99)? What if there is no answer (e.g., `-minstd=c23`)?

FWIW, my idea is to broaden the concept CMake has of "usage
requirements" to not be so CMake-centered and to encompass things like
"you need an rpath to X to use my libraries" or even "here's an entry
for `PYTHONPATH` to use my Python code". ISO C++'s SG15 has started
discussion of such things with an eye towards standardization here:

    https://github.com/isocpp/pkg-fmt

--Ben

[1]https://cmake.org/cmake/help/latest/prop_tgt/C_STANDARD.html

      parent reply	other threads:[~2022-12-22  2:42 UTC|newest]

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

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=Y6PELi32YhG/VKvV@farprobe \
    --to=ben.boeckel@kitware.com \
    --cc=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).