Previous: Option file format, Up: Options


8.2 选项属性

     Condition({defined (USE_CYGWIN_LIBSTDCXX_WRAPPERS)})

选项记录的第二个域可以指定下列属性:

Common
选项对所有语言和目标都有效。
Target
选项对所有语言都有效,但是目标特定的。
Driver

language
当编译给定语言时,选项有效。

可以为多个不同的语言指定同一个选项。每个语言language必须已经被之前的Language记录声明过。参见Option file format

RejectDriver
The option is only handled by the compilers proper (cc1 etc.) and should not be accepted by the driver.
RejectNegative
选项没有“no-”形式。所有由“f”,“W”或者“m”开始的选项都被假设具有“no-”形式,除非使用这个属性。
Negative(othername)
选项将会关掉另一个选项othername,这是去掉前导符“-”的选项名字。这会通过Negative属性来传播一连串的选项关闭行为。
Joined
Separate
选项接受一个强制参数。Joined指示选项和参数可以被包含在同一个argv项中(例如 -mflush-func=name)。Separate指示选项和参数可以为分开的argv项(如-o)。一个选项允许同时具有这两个属性。
JoinedOrMissing

选项接受一个可选参数。如果参数给出,则会作为选项本身的argv项的一部分。

该属性不能和JoinedSeparate一起使用。

MissingArgError(message)

UInteger
选项的参数是一个非负整数。选项解析器将会在传给选项处理前检测并转换参数。
NoDriverArg
For an option marked Separate, the option only takes an argument in the compiler proper, not in the driver. This is for compatibility with existing options that are used both directly and via -Wp,; new options should not have this property.
Var(var)
该选项的状态将被存储在变量var中。存储状态的方式取决于选项的类型:

选项处理脚本通常会在options.c中声明var,并且在起动时间将其初始化为0。你可以使用VarExistsInit来修改这种行为。

Var(var, set)
选项控制一个整数变量var,并且当var等于set时起作用。当使用选项的正面形式时,选项解析器会把变量置为set,当使用“no-”形式的时候,置为!set

var的声明方式与上面描述的单一参数形式的具有相同的方式。

VarExists
Var属性指定的变量已经存在。这样,就不会有任何定义被增加到options.c中。

应该只有在options.c之外声明了该变量的时候,才使用这个属性。

Init(value)
由属性Var指定的变量应该被静态初始化为value
Mask(name)
选项与target_flags变量(参见Run-time Target)中的一个位相关联,并且当该位被置位时才起作用。你还可以指定Var去选择一个变量,而不只是target_flags

选项处理脚本将会自动为选项分配一个唯一的位。如果选项与‘target_flags’关联,则脚本会将宏MASK_name设为合适的位掩码。它还会声明一个TARGET_name宏,当选项起作用时其值为1,否则为0。如果使用Var将选项关联到不同的变量上,则相关的宏分别叫做OPTION_MASK_nameOPTION_name

可以使用 MaskExists 来禁止自动位分配。

InverseMask(othername)
InverseMask(othername, thisname)
选项是具有Mask(othername)属性的另一个选项的反面。如果给出了thisname,则选项处理脚本会声明一个TARGET_thisname宏,当选项起作用时其为1,否则为0。
MaskExists
Mask属性指定的掩码已经存在。这样,就不会有MASKTARGET定义被增加到options.h中。

该属性的主要目的用来支持同义选项。第一个选项应该使用‘Mask(name)’并且其它的应该使用‘Mask(name) MaskExists’。

Alias(opt)
Alias(opt, arg)
Alias(opt, posarg, negarg)
The option is an alias for -opt. In the first form, any argument passed to the alias is considered to be passed to -opt, and -opt is considered to be negated if the alias is used in negated form. In the second form, the alias may not be negated or have an argument, and posarg is considered to be passed as an argument to -opt. In the third form, the alias may not have an argument, if the alias is used in the positive form then posarg is considered to be passed to -opt, and if the alias is used in the negative form then negarg is considered to be passed to -opt.

Aliases should not specify Var or Mask or UInteger. Aliases should normally specify the same languages as the target of the alias; the flags on the target will be used to determine any diagnostic for use of an option for the wrong language, while those on the alias will be used to identify what command-line text is the option and what text is any argument to that option.

When an Alias definition is used for an option, driver specs do not need to handle it and no ‘OPT_’ enumeration value is defined for it; only the canonical form of the option will be seen in those places.

Ignore
This option is ignored apart from printing any warning specified using Warn. The option will not be seen by specs and no ‘OPT_’ enumeration value is defined for it.
SeparateAlias
For an option marked with Joined, Separate and Alias, the option only acts as an alias when passed a separate argument; with a joined argument it acts as a normal option, with an ‘OPT_’ enumeration value. This is for compatibility with the Java -d option and should not be used for new options.
Warn(message)
If this option is used, output the warning message. message is a format string, either taking a single operand with a ‘%qs’ format which is the option name, or not taking any operands, which is passed to the ‘warning’ function. If an alias is marked Warn, the target of the alias must not also be marked Warn.
Report
选项的说明应该通过-fverbose-asm来打印。
Undocumented
选项有意的不提供文档,并且不应该包括在--help输出中。
Condition(cond)
选项应该只在预处理程序条件cond为真时才被接受。注意即使cond为假时,任何与选项相关的C声明也会存在;cond只是简单的控制选项是否被接受,以及是否在--help输出中被打印。
Save
Build the cl_target_option structure to hold a copy of the option, add the functions cl_target_option_save and cl_target_option_restore to save and restore the options.