Compile pragma
The compile pragma can be used to compile and link a C/C++ source file with the project:
This pragma can take three forms. The first is a simple file input:
{.compile: "myfile.cpp".}
The second form is a tuple where the second arg is the output name strutils formatter:
{.compile: ("file.c", "$1.o").}
Note: Nim computes a SHA1 checksum and only recompiles the file if it has changed. One can use the -f command-line option to force the recompilation of the file.
Since 1.4 the compile pragma is also available with this syntax:
{.compile("myfile.cpp", "--custom flags here").}
As can be seen in the example, this new variant allows for custom flags that are passed to the C compiler when the file is recompiled.
当前内容版权归 nim-lang.org 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 nim-lang.org .