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.
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:
var
a {.codegenDecl: "$# progmem $#".}: int
will generate this C code:
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:
proc myinterrupt() {.codegenDecl: "__interrupt $# $#$#".} =
echo "realistic interrupt handler"
will generate this code:
__interrupt void myinterrupt()
当前内容版权归 nim-lang.org 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 nim-lang.org .