gpt4 book ai didi

c++ - 使用 C++ Gradle : How to change compiler options?

转载 作者:行者123 更新时间:2023-11-27 23:46:34 25 4
gpt4 key购买 nike

我开始使用 Gradle,并且刚刚构建了一些东西。构建生成文件“options.txt”:

-x
c++
-c
-I
/path/to/project/src/main/headers
-I
/path/to/project/src/hello/headers
-m64

他们为我选择编译器选项真是太棒了,但例如,我想用 -std=c++17 和 -Wall 和 -Wextra 编译我的东西。那么如何将这些标志添加到 g++ 选项中呢?

最佳答案

只需在 build.gradle 的“模型”中添加以下内容:

toolChains {
gcc(Gcc) {
eachPlatform {
cppCompiler.withArguments { args ->
args << "-std=c++17"
}
cppCompiler.withArguments { args ->
args << "-Wall"
}
cppCompiler.withArguments { args ->
args << "-Wextra"
}
}
}
}

关于c++ - 使用 C++ Gradle : How to change compiler options?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50086350/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com