我可以在 C++ 中使用字符串作为注释吗?

Can I use strings as comments in c++?

在Python中,有两种评论。
第一个使用#(单行注释)

# This is a comment
This_is_not()

其他使用"""/'''(多行注释)

"""
This is a comment
"""
'''
Yet another comment
'''
NOT_a_comment()



在 C++ 中,有两种类型的注释。
第一个使用//(单行注释)

// This is a comment
This_is_not_a_comment();

其他使用/*/*/(多行注释)

/*
This is a comment
*/
This_is____well_you_get_the_idea();



我的问题是,
我可以在 C++ 中使用字符串作为注释吗?
如果我这样做,gcc 会给我一个警告。

warning: statement has no effect [-Wunused-value]
    "This is a comment";
    ^~~~~~~~~~~~~~~~~~~

但如果我只是忽略警告(可能 -Wno-unused-value)就可以了,对吧?

编译器在编译期间会跳过注释,而值及其赋值则不会。最好避免使用未使用的字符串值,因为尽管它们未被使用,但它们至少包含在编译中。 OTOH,忽略评论。