Update pragmas.txt (#6006)
Added more info on how the format strings work for codegenDecl
This commit is contained in:
parent
245a1fe8d7
commit
f682bb6de0
1 changed files with 23 additions and 2 deletions
|
|
@ -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
|
||||
-----------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue