Compile pragma
The compile pragma can be used to compile and link a C/C++ source file with the project:
{.compile: "myfile.cpp".}
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 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 .