0

When I try to set an alias where I will type w++17 it should correspond to w++17 -g++ main.cpp -Wall -Wextra -pedantic -Weffc++ -Wold-style-cast -Woverloaded-virtual -fmax-errors=3

I do it in Poweshell terminal using VSCODE. When I try to set the alias I do:

Set-Alias -Name w++17 -Value g++ main.cpp -Wall -Wextra -pedantic -Weffc++ -Wold-style-cast -Woverloaded-virtual -fmax-errors=3

I get the following error:

Set-Alias : A positional parameter cannot be found that accepts argument 'main.cpp'.
At line:1 char:1
+ Set-Alias -Name w++17 -Value g++ main.cpp -Wall -Wextra -pedantic -We ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-Alias], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetAliasCommand

It looks like I cant set an alias containing multiple values/arguments?

Kevin R
  • 25
  • 3

1 Answers1

1

Try this wrapper..

Function wplusplus { (w++17 -g++ main.cpp -Wall -Wextra -pedantic -Weffc++ -Wold-style-cast -Woverloaded-virtual -fmax-errors=3) }

Set-Alias -Name wpp17 -Value wplusplus
  • Oh really nice! The only problem is that when I restart vscode all the functions and aliases that I have created gets removed and I have to define them again. Can I not save them? – Kevin R May 05 '22 at 16:31
  • check out this StackOverflow post on profiles; https://stackoverflow.com/questions/24914589/how-to-create-permanent-powershell-aliases Please mark answer as such if it helped you, thanks! – jack_skellington May 06 '22 at 12:27