warning pragma Directive

Pragma directive that modifies the behavior of compiler warning messages.

#pragma warning( warning-specifier : warning-number-list [; warning-specifier : warning-number-list...] )

Parameters

Item Description
warning-specifier
Behavior to set for the specified warnings. This parameter can take one of the values listed in the following table.
Value Description
once Display the message of the warnings with the specified numbers only once.
default Reset the behavior of the warnings with the specified numbers to their default value. This also has the effect of turning a warning on that is off by default. The warning will be generated at its default level.
1, 2, 3, 4 Apply the specified level to the warnings with the specified numbers. This also has the effect of turning a warning on that is off by default.
disable Do not issue the warnings with the specified numbers.
error Report the warnings with the specified numbers as errors.

warning-number-list

White space-delimited list of the numbers of the warnings to modify the behavior of.

Remarks

You can specify any number of distinct warning behavior changes within the same warning pragma by separating the changes with semicolons.

The compiler will add 4000 to any warning number that is between 0 and 999. For warning numbers greater than 4699, (those associated with code generation) the warning pragma has effect only when placed outside function definitions. The pragma is ignored if it specifies a number greater than 4699 and is used inside a function.

The HLSL warning pragma does not support the push and pop functionality of the warning pragma included in the C++ compiler.

Examples

The following example disables warnings 4507 and 4034, displays warning 4385 once, and reports warning 4164 as an error.

#pragma warning( disable : 4507 34; once : 4385; error : 164 )

The preceding example is functionally equivalent to the following:

#pragma warning( disable : 4507 34 )
#pragma warning( once : 4385 )
#pragma warning( error : 164 )

See also

Preprocessor Directives (DirectX HLSL)

#pragma Directive (DirectX HLSL)