diff options
author | Dan <bogdan.diverse@gmail.com> | 2017-06-21 16:36:50 +0300 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-06-21 15:36:50 +0200 |
commit | f682bb6de0df2b967ec629a043c2736d97aca0ad (patch) | |
tree | 1c257087b8109c3083979c84228e2e3e3183cb74 /doc/manual | |
parent | 245a1fe8d78efcba6a56922d0e53a2419397cd46 (diff) | |
download | Nim-f682bb6de0df2b967ec629a043c2736d97aca0ad.tar.gz |
Update pragmas.txt (#6006)
Added more info on how the format strings work for codegenDecl
Diffstat (limited to 'doc/manual')
-rw-r--r-- | doc/manual/pragmas.txt | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/doc/manual/pragmas.txt b/doc/manual/pragmas.txt index d30c37ff7..bd90cd73d 100644 --- a/doc/manual/pragmas.txt +++ b/doc/manual/pragmas.txt @@ -1006,16 +1006,37 @@ CodegenDecl pragma ------------------ The ``codegenDecl`` pragma can be used to directly influence Nim's code -generator. It receives a format string that determines how the variable or -proc is declared in the generated code: +generator. It receives a format string that determines how the variable +or proc is declared in the generated code. + +For variables $1 in the format string represents the type of the variable +and $2 is the name of the variable. + +The following Nim code: .. code-block:: nim var a {.codegenDecl: "$# progmem $#".}: int + +will generate this C code: + +.. code-block:: c + int progmem a + +For procedures $1 is the return type of the procedure, $2 is the name of +the procedure and $3 is the parameter list. +The following nim code: + +.. code-block:: nim proc myinterrupt() {.codegenDecl: "__interrupt $# $#$#".} = echo "realistic interrupt handler" +will generate this code: + +.. code-block:: c + __interrupt void myinterrupt() + InjectStmt pragma ----------------- |