Skip to content

Instantly share code, notes, and snippets.

@ghost355
Last active June 19, 2016 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghost355/1dd2b7e8c79e221d56141f0980a1c312 to your computer and use it in GitHub Desktop.
Save ghost355/1dd2b7e8c79e221d56141f0980a1c312 to your computer and use it in GitHub Desktop.
;; Build and Run C code from Spacemacs
;; If the code hasn't compilied then we build the code and create an execute file with a buffer's name without an extensions in the current folder
;; Or just run the program in bottom pop-up shell window
;; P.Pavlov 2016
(defun execute-c-program ()
(interactive)
(let ((c-code-compile (concat "gcc " (buffer-name) " -o " (file-name-base)))
(c-code-run (concat "./" (file-name-base))))
(if (not (locate-file (file-name-base) "."))
(shell-command c-code-compile))
(async-shell-command c-code-run))
(global-set-key [C-f1] 'execute-c-program))
@tuxador
Copy link

tuxador commented Jun 16, 2016

thank you P.Pavlov !
BTW i'm a python newbie , and my only experience with C compilation is for installing apps in my GNU/Linux laptop.

| Yahyaoui Kaddour aka @kaddourkardio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment