Skip to content

Instantly share code, notes, and snippets.

@death
Created September 23, 2018 18:06
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 death/4e273d14e671a3c64f3be10cab2aa1b2 to your computer and use it in GitHub Desktop.
Save death/4e273d14e671a3c64f3be10cab2aa1b2 to your computer and use it in GitHub Desktop.
Ad hoc C++ generation
CL-USER> (defmacro c++ (&rest args)
`(constantia:out
(:use smack/backend/c++-out:*c++-out-dispatch-table*)
(:to (make-instance 'constantia:indenting-stream :stream *standard-output*))
,@args))
C++
CL-USER> (c++ (:include "iostream" :system)
(:fndef "main" () "int"
"std::cout << \"hi\";" (:%)
(:return 0)))
#include <iostream>
int main()
{
std::cout << "hi";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment