all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Compiling C++ in emacs
@ 2008-11-13 13:40 Richard Riley
  2008-11-14 13:27 ` Kevin Rodgers
       [not found] ` <mailman.351.1226669412.26697.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 4+ messages in thread
From: Richard Riley @ 2008-11-13 13:40 UTC (permalink / raw)
  To: help-gnu-emacs


I have the function below which is for C. Does anyone have an
extension/idea for compiling and linking C++ based on file extension?

,----
| (defun do-compile()
|   
|   (unless (or (file-exists-p "makefile")
| 	      (file-exists-p "Makefile"))
|     (set (make-local-variable 'compile-command)
| 	 (let ((file (file-name-nondirectory buffer-file-name)))
| 	   (format "%s -o %s %s %s %s %s"
| 		   (or (getenv "CC") "gcc")
| 		   (file-name-sans-extension file)
| 		   (or (getenv "GTKFLAGS") "`pkg-config --cflags --libs gtk+-2.0`")
| 		   (or (getenv "CPPFLAGS")"-DDEBUG=9")
| 		   (or (getenv "CFLAGS") "-std=c99 -pedantic -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion  -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -g")
| 		   file)))
|     
|     )
|   (compile compile-command)
|   )
| 
| 
`----

Thanks,

r.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Compiling C++ in emacs
  2008-11-13 13:40 Compiling C++ in emacs Richard Riley
@ 2008-11-14 13:27 ` Kevin Rodgers
       [not found] ` <mailman.351.1226669412.26697.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2008-11-14 13:27 UTC (permalink / raw)
  To: help-gnu-emacs

Richard Riley wrote:
> I have the function below which is for C. Does anyone have an
> extension/idea for compiling and linking C++ based on file extension?
> 
> ,----
> | (defun do-compile()
> |   
> |   (unless (or (file-exists-p "makefile")
> | 	      (file-exists-p "Makefile"))
> |     (set (make-local-variable 'compile-command)
> | 	 (let ((file (file-name-nondirectory buffer-file-name)))
> | 	   (format "%s -o %s %s %s %s %s"
> | 		   (or (getenv "CC") "gcc")
> | 		   (file-name-sans-extension file)
> | 		   (or (getenv "GTKFLAGS") "`pkg-config --cflags --libs gtk+-2.0`")
> | 		   (or (getenv "CPPFLAGS")"-DDEBUG=9")
> | 		   (or (getenv "CFLAGS") "-std=c99 -pedantic -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion  -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -g")
> | 		   file)))
> |     
> |     )
> |   (compile compile-command)
> |   )
> | 
> | 
> `----

(if (equal (file-name-extension buffer-file-file) "cc")
     (progn
       ;; C++ stuff goes here
       )
   )

-- 
Kevin Rodgers
Denver, Colorado, USA





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Compiling C++ in emacs
       [not found] ` <mailman.351.1226669412.26697.help-gnu-emacs@gnu.org>
@ 2008-11-16 20:00   ` Richard Riley
  2008-11-16 20:41     ` Richard Riley
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Riley @ 2008-11-16 20:00 UTC (permalink / raw)
  To: help-gnu-emacs

Kevin Rodgers <kevin.d.rodgers@gmail.com> writes:

> Richard Riley wrote:
>> I have the function below which is for C. Does anyone have an
>> extension/idea for compiling and linking C++ based on file extension?
>>
>> ,----
>> | (defun do-compile()
>> |   |   (unless (or (file-exists-p "makefile")
>> | 	      (file-exists-p "Makefile"))
>> |     (set (make-local-variable 'compile-command)
>> | 	 (let ((file (file-name-nondirectory buffer-file-name)))
>> | 	   (format "%s -o %s %s %s %s %s"
>> | 		   (or (getenv "CC") "gcc")
>> | 		   (file-name-sans-extension file)
>> | 		   (or (getenv "GTKFLAGS") "`pkg-config --cflags --libs gtk+-2.0`")
>> | 		   (or (getenv "CPPFLAGS")"-DDEBUG=9")
>> | 		   (or (getenv "CFLAGS") "-std=c99 -pedantic -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion  -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -g")
>> | 		   file)))
>> |     |     )
>> |   (compile compile-command)
>> |   )
>> | | `----
>
> (if (equal (file-name-extension buffer-file-file) "cc")
>     (progn
>       ;; C++ stuff goes here
>       )
>   )

(defun make-command()
  
  (if   (or (file-exists-p "makefile")
	    (file-exists-p "Makefile"))
      nil
    (let ((file (file-name-nondirectory buffer-file-name)))
      (if (equal (file-name-extension buffer-file-name) "cc")
	  (progn
	    (format "%s %s %s -o %s"
		    (or (getenv "CC") "g++")
		    (or (getenv "CPPFLAGS")"-Wall -g") file
		    (file-name-sans-extension file)
		    ))
	(format "%s -o %s %s %s %s %s"
		(or (getenv "CC") "gcc")
		(file-name-sans-extension file)
		(or (getenv "GTKFLAGS") "`pkg-config --cflags --libs gtk+-2.0`")
		(or (getenv "CPPFLAGS")"-DDEBUG=9")
		(or (getenv "CFLAGS") "-std=c99 -pedantic -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion  -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -g")
		file)
	))))


thanks


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Compiling C++ in emacs
  2008-11-16 20:00   ` Richard Riley
@ 2008-11-16 20:41     ` Richard Riley
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Riley @ 2008-11-16 20:41 UTC (permalink / raw)
  To: help-gnu-emacs


Corrected a small error so Makefile or makefile works now and also to
look for SConstruct file first to use the fantastic scons make tool.

,----
| (defun do-compile()
|   (compile (make-command))
|   )
| 
| 
| 
| (defun make-command()
|   
|   (if   (or (file-exists-p "makefile")
| 	    (file-exists-p "Makefile"))
|       "make" )
|   (if  (file-exists-p "SConstruct")
|       "scons"
|     (let ((file (file-name-nondirectory buffer-file-name)))
|       (if (equal (file-name-extension buffer-file-name) "cc")
| 	  (progn
| 	    (format "%s %s %s -o %s"
| 		    (or (getenv "CC") "g++")
| 		    (or (getenv "CPPFLAGS")"-Wall -g") "*.cc"
| 		    (file-name-sans-extension file)
| 		    ))
| 	(format "%s -o %s %s %s %s %s"
| 		(or (getenv "CC") "gcc")
| 		(file-name-sans-extension file)
| 		(or (getenv "GTKFLAGS") "`pkg-config --cflags --libs gtk+-2.0`")
| 		(or (getenv "CPPFLAGS")"-DDEBUG=9")
| 		(or (getenv "CFLAGS") "-std=c99 -pedantic -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion  -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -g")
| 		file)
| 	))))
| 
| 
| (defun do-lint()
|   (interactive)
|   (set (make-local-variable 'compile-command)
|        (let ((file (file-name-nondirectory buffer-file-name)))
| 	 (format "%s %s %s"
| 		 "splint"
| 		 "+single-include -strict -compdef -nullpass -preproc +matchanyintegral -internalglobs -I/usr/include/gtk-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/cairo/ -I/usr/include/pangomm-1.4/pangomm/"
| 		 file
| 		 )))
|   (message compile-command)
|   (compile compile-command)
|   )
| 
| (defun do-cdecl () 
|   (interactive)
|   (shell-command
|    (concat "cdecl explain \"" (buffer-substring (region-beginning)
| 						(region-end)) "\""))
|   )
| 
`----


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-11-16 20:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-13 13:40 Compiling C++ in emacs Richard Riley
2008-11-14 13:27 ` Kevin Rodgers
     [not found] ` <mailman.351.1226669412.26697.help-gnu-emacs@gnu.org>
2008-11-16 20:00   ` Richard Riley
2008-11-16 20:41     ` Richard Riley

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.