I've noticed that both -std
and --std
works for setting the standard for compiling. What is the difference between using a -
and --
before std
?
I've googled and found this, but it doesn't seem to mention anything about a single hyphen vs a double hyphen before a std
.
-std=c99
is ok but -std c99
is an error. --std c99
is valid as is --std=c99
. That's the only difference.
You can see that they map to the same action in opts-common.c:
struct option_map
{
/* Prefix of the option on the command line. */
const char *opt0;
/* If two argv elements are considered to be merged into one option,
prefix for the second element, otherwise NULL. */
const char *opt1;
/* The new prefix to map to. */
const char *new_prefix;
/* Whether at least one character is needed following opt1 or opt0
for this mapping to be used. (--optimize= is valid for -O, but
--warn- is not valid for -W.) */
bool another_char_needed;
/* Whether the original option is a negated form of the option
resulting from this map. */
bool negated;
};
static const struct option_map option_map[] =
{
...
{ "--std=", NULL, "-std=", false, false },
{ "--std", "", "-std=", false, false },
...
};