argagg icon indicating copy to clipboard operation
argagg copied to clipboard

Support for options like -std=foo

Open Manu343726 opened this issue 6 years ago • 3 comments

Hi,

I would like to know if argagg could implement support for short options with =value syntax, like -std=c++11 of GCC and Clang

Manu343726 avatar Jan 28 '19 14:01 Manu343726

After studying your code a bit I think this could be done by also scanning short flags for an = sign. Then if one is found assume the flag is not a combination of flags, i.e. with three flags -a, -b, -c, the following is not valid -abc=foo ("No flag named abc" error), but -a=foo is.

Manu343726 avatar Jan 28 '19 18:01 Manu343726

This looks like a good idea since GCC supports it as is. I'll take a look at implementation, maybe this weekend.

Some notable behavior cases with GCC:

  • gcc test.c -std=c11 works fine
  • gcc test.c -std c11 doesn't work, says -std is not an option
  • gcc test.c -std=foo doesn't work either, says that -std=foo is not an option

That seems to imply that support -long_name like #17 mentions is a possible solution in that one doesn't make a -std option with an argument but rather enumerates -std=c99 and -std=c11 as individual -long_name options.

vietjtnguyen avatar Jan 29 '19 09:01 vietjtnguyen

Looks like that last hypothesis regarding -std=* options being individually enumerated options rather than an argument-receiving one is correct: https://github.com/gcc-mirror/gcc/blob/48bbcd968d172c4e59d874c5fd831bcbf54cd221/gcc/c-family/c.opt#L1937-L2101

vietjtnguyen avatar Feb 07 '19 02:02 vietjtnguyen