How can I shorten commands for command line?

403 Views Asked by At

I use Windows, and I compile c++ files a lot, I always type

g++ -Wall -Wextra -Wshadow -Wfloat-equal -O2 -std=c++14 -DALEXPC -o smth smth.cpp

So I don't want to always type this whole command is there a way to use some kind of an alias to use it instead of

g++ -Wall -Wextra -Wshadow -Wfloat-equal -O2 -std=c++14 -DALEXPC -o

I tried using doskey but it doesn't work. I wrote

doskey runcpp = g++ -Wall -Wextra -Wshadow -Wfloat-equal -O2 -std=c++14 -DALEXPC -o

and tried to run runcpp fast.exe main.cpp and the thing is it doesn't read the filenames after the runcpp.

1

There are 1 best solutions below

1
On

create a text file and copy this line to it.

g++ -Wall -Wextra -Wshadow -Wfloat-equal -O2 -std=c++14 -DALEXPC -o %1 %2

rename text file to cmp.bat and run this command in Command Prompt (CMD) to compile main.cpp

cmp.bat fast.exe main.cpp