What is the most efficient way to run programs in Emacs after compiling Mx

I started using Mx compilation to compile programs in say, C.

What is the most efficient way to run an executable, for example. a.out. At the moment I am using M -! ./ a.out. Basically, what is the best code compilation procedure?

Almost all textbooks mention how compilation is done, but I have not seen the one who solved this problem?

Thanks Samuel

+4
source share
4 answers

I just simply add a run command at the end of the assembly:

Mx compile RET gmake && ./a.out 

&& will tell the shell to only a.out when the compilation is successful.

Although I often run the program from an existing shell buffer ( Mx shell ) or from one of the many shells that I manage with a package very similar to screen .

+3
source

I use the smart-compile + extension, it allows you to specify fairly convenient rules depending on the name of the file / buffer you are editing. For example, in my .emacs, I specify the following rule when running smart-compile in the project’s eilers file:

 (add-to-list 'smart-compile-alist '("euler.*\\.[Cc]+[Pp]*$" . "g++ -O2 -Wall -pedantic -Werror -Wreturn-type %f -lm -lgmpxx -lgmp -o ../bin/%n && time ../bin/%n") ) 

First you specify the file name template for the rule, then the path where it should be executed, and then the compilation command. In the above case, I add && time ../ bin /% n to run the program immediately after it has successfully compiled.

+3
source

My first choice is for interactive development; code, upload files to REPL, resolve errors (with Cx `, as with Mx compilation), and then play the code in REPL.

If this is not an option, I use eshell as a generic REPL. Compile, switch to eshell, run, verify, retry.

0
source

Add the rule to your make file to compile and run your program, so Mx compile will compile and run, check, valgrind-test ... all

0
source

Source: https://habr.com/ru/post/1305240/


All Articles