This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gcc command-line option parsing doc


I was trying to find my way in another piece of code and I ended up look
at the command-line option parsing code. Here is a smallish bit you
might consider adding to the internals doc. I have not figured out yet
how the doc is built which is why this is not sent as a patch to the
source files.

regards,
Mathieu

gcc supports a lot of command-line options and a lot of options come in
multiple flavors: typically, most -Wfoo switch come with a -Wnofoo
switch but some -Wnofoo switches exist without a corresponding -Wfoo
switch. The -fbar switches behave in a similar way.
                                                                                                                                                        
The logic used by gcc to parse these command-line options is mainly
located in the opts.c file and more specifically, in the handle_option
function. This function uses the find_opt function to perform a search
over the list of acceptable options for each user-provided argument.
This search is done through a list of struct cl_option which is
generated at build time by the scripts optc-gen.awk, opt-gather.awk,
opth-gen.awk. These scripts generate options.c and options.h (that is,
you will find them in your objdir/gcc directory) from the *.opt
files gcc/common.opt, gcc/c.opt, ...

-- 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]