I\'m trying to set up a \"gcc99\" alias in Windows PowerShell which is equal to \"gcc -std=C99 -pedantic -Wall\". The idea is to use fewer keystrokes to ensure that GCC is r
Aliases in PowerShell are different from aliases in Unix shells. You can only alias the name of a cmdlet, function or program, not include parameters. Quoting from Get-Help Set-Alias:
NAME
Set-Alias
SYNOPSIS
Creates or changes an alias (alternate name) for a cmdlet or other command
element in the current Windows PowerShell session.
SYNTAX
Set-Alias [-Name] [-Value] [-Description ] [-Force]
[-Option ] [-PassThru] [-Scope ] [-Confirm]
[-WhatIf] []
DESCRIPTION
The Set-Alias cmdlet creates or changes an alias (alternate name) for a
cmdlet or for a command element, such as a function, a script, a file,
or other executable. You can also use Set-Alias to reassign a current alias
to a new command, or to change any of the properties of an alias, such as
its description. Unless you add the alias to the Windows PowerShell profile,
the changes to an alias are lost when you exit the session or close Windows
PowerShell.
What you can do to run an external program with a default set of arguments is to define that default set as an array and run the program like this:
$CARGS = '-std=C99', '-pedantic', '-Wall'
gcc $CARGS -more arguments here ...
As @ChrisN suggested in the comments below, if you want the variable $CARGS
pre-defined in all your PowerShell instances, you can add it to a custom PowerShell profile (e.g. %UserProfile%\Documents\WindowsPowerShell\profile.ps1
for your user).