2

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
    You should probably read about `make` and makefiles. The documentation for the GNU version can be found [here](https://www.gnu.org/software/make/manual/make.html). – G.M. Jul 26 '20 at 11:02
  • `doskey runcpp=g++ $1 -o $2`: `runcpp main.cpp fast.exe`. You have to put positional parameters when defining the macro. – Manuel Jul 26 '20 at 14:15

1 Answers1

0

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
Ali Fallah
  • 138
  • 8