Skip to content

Instantly share code, notes, and snippets.

@fowlmouth
Created May 30, 2013 18:30
Show Gist options
  • Save fowlmouth/5680007 to your computer and use it in GitHub Desktop.
Save fowlmouth/5680007 to your computer and use it in GitHub Desktop.
import macros
from strutils import format
macro constStr* (name; str: expr[string]): stmt {.immediate.}=
##need a check for top level statement??
result = """{.emit: "prog_char $1_data[] PROGMEM = \"$2\"; ".}
var $1_data {.importc, nodecl.}: array[$3, char]
template $1: cstring = $1_data[0].addr""".format(name, str, str.strval.len).parseStmt
result.repr.echo
constStr string_0, "String 0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment