visual studio suppress warning code example

Example 1: powershell suppress error

You have a couple of options. The easiest involve using the ErrorAction settings.

-Erroraction is a universal parameter for all cmdlets. If there are special commands you want to ignore you can use -erroraction 'silentlycontinue' which will basically ignore all error messages generated by that command. You can also use the Ignore value (in PowerShell 3+):

Unlike SilentlyContinue, Ignore does not add the error message to the $Error automatic variable.

If you want to ignore all errors in a script, you can use the system variable $ErrorActionPreference and do the same thing: $ErrorActionPreference= 'silentlycontinue'

See about_CommonParameters for more info about -ErrorAction. See about_preference_variables for more info about $ErrorActionPreference.

Example 2: gcc suppress warning inline

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"

void f(int a, int b)
{
    std::cout << a << '\n';
    // we are not using b!
}

#pragma GCC diagnostic pop