'Is there a direct way to get clear details on gcc acceptable option values (e.g. for -std) without grep-ing through irrelevant material?

The gcc (or g++) compiler has a -std option to specify the language standard to use for compiling C or C++. At the top level one can see that this option exists.

gcc --help

-std=<standard> Assume that the input sources are for <standard>

However, different versions of the gcc compilers will have a different set of supported standards.

Is there a simple and direct way to ask for detailed help on just that option so that one gets the details about accepted standards, etc. for just that option?

I have done kludges in the past where I dumped exhaustive help about all manner of options and then tried to filter out just the lines I wanted by piping it through grep (see footnote). I'm not asking for that. I'm asking for a way to get the details for just the option one wants (such as -std) directly without any such ugly kludge. (Besides being awkward, the ugly kludges become problematic regarding getting all the relevant detail lines, including those lines concerning the option that don't happen to include whatever search term one is using to filter without knowing the extent of surrounding help text.)

It's hard to believe there is no direct way to do this. Surely other people must want to be able to get detailed information about some option without getting mounds of unrelated other stuff besides. I'm hoping someone can tell me the simple method I'm missing. It's not this...

gcc --help=std

cc1: warning: unrecognized argument to --help= option: ‘std’


*Sedenion was kind enough to provide the following example of the grep approach, which some readers of this question may find helpful.

gcc -Q --help=c++ | grep "\-std="

If someone only wants lines containing a known string, something like this could serve, if one remembers all the arguments and syntax details. If one wants other lines in the same entry for some gcc option, that becomes trickier since one doesn't necessarily know in advance what lines to capture. (Remember that -std is the example of the more general need for a better help option.)



Solution 1:[1]

Sadly, it seems that no one knows of a feature in gcc itself that would provide what I was seeking, i.e. a direct way to use gcc --help to get the detailed information about a particular option for that version of gcc.

I appreciate the comments by RetiredNinja that fall back on the web documentation. Even though that is a tacit indication that the gcc command itself is not (yet?) up to the task, for now that does seem to be the next best general purpose alternative.

A general procedure could follow steps like these.

  1. Get the relevant gcc --version
  2. Use the version to find and click on the most relevant GCC Manual at https://gcc.gnu.org/onlinedocs/
  3. Find and then click on any of the links (toward the bottom) for either "Option Index" or "[Index]" (but NOT on the "Option Index" for the "Short Table of Contents").
  4. On the Option Index page, click on the link to "Jump to:" the section for the relevant starting character.
  5. If there are multiple choices for the same option word (e.g. 4 entries for "std:"), one can try what seems the most appropriate (and then try another if that doesn't have what you were looking for).

But wouldn't it be much more handy (and not even dependent on the internet) if one could just enter that option name in a single command, perhaps something more or less like the following?

gcc --help=optionName

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1