制作多行注释-块注释

有没有办法在记事本 + + 编辑器中注释 CMake 中的一个块?

我试过在谷歌上搜索,但找不到太多。

我们需要帮助,谢谢,

83295 次浏览

There is no notion of a block comment in CMake syntax. However, to comment several lines at once, select the required lines and hit CTRL+Q.

If the file is a .txt file (e.g. CMakeLists.txt), you can either set Notepad++ to always treat .txt files as CMake files (in Settings -> Style configurator select CMakeFile and add " txt" to "User ext.") or for just that file you can set the Language to CMake.

if(FALSE) # fake a block comment


endif()

As of CMake 3.0 there is a special syntax for block comments which start with #[[ and ends with ]] at the end of block comment. See CMake documentation for further explanation.

You can also put a number of equal signs between the brackets as long as the number between the opening [[ and closing ]] are both the same. Ex.

#[===[
hello
]] <- this is not the closing
]===]
# ^ this is the closing

Some editors and IDEs do not support it yet.

Since CMake version 3.0 there are block comments.

Example from the CMake manual:

#[[This is a bracket comment.
It runs until the close bracket.]]
message("First Argument\n" #[[Bracket Comment]] "Second Argument")