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 running in c99 mode. (I've tried my best to adapt the guidelines in the following post to Windows PowerShell: Setting std=c99 flag in GCC)
When I try to compile after setting up such an alias (exhibit 1 below), I receive an error. As reference, I don't receive this error if I use the extended command to compile (exhibit 2 below). As a test, I tried setting gc99 as an alias for "gcc" (no additional values) and it worked fine (exhibit 3 below). Please ignore the many warnings which I have yet to address in code :)
Any suggestions?
(I'm not sure why my captions aren't showing up for the images below. I'm using the auto-created format for pictures, e.g., for the first image: "Caption" followed by "1: link" on the next line.)
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
: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:
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).