gpt4 book ai didi

c++ - 找到有问题的宏

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:08:25 25 4
gpt4 key购买 nike

自从加入项目以来,我的编译输出一直是这样的:

[  0%] Building CXX object lib-tests/gmock/CMakeFiles/gmock_main.dir/gtest/src/gtest-all.cc.o
<command-line>:0:23: warning: ISO C99 requires whitespace after the macro name
<command-line>:0:20: warning: ISO C99 requires whitespace after the macro name
<command-line>:0:23: warning: ISO C99 requires whitespace after the macro name
<command-line>:0:20: warning: ISO C99 requires whitespace after the macro name
[ 0%] Building CXX object lib-tests/gmock/CMakeFiles/gmock_main.dir/src/gmock-all.cc.o
<command-line>:0:23: warning: ISO C99 requires whitespace after the macro name
<command-line>:0:20: warning: ISO C99 requires whitespace after the macro name
<command-line>:0:23: warning: ISO C99 requires whitespace after the macro name
<command-line>:0:20: warning: ISO C99 requires whitespace after the macro name
[ 0%] Building CXX object lib-tests/gmock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o
<command-line>:0:23: warning: ISO C99 requires whitespace after the macro name
<command-line>:0:20: warning: ISO C99 requires whitespace after the macro name
<command-line>:0:23: warning: ISO C99 requires whitespace after the macro name
<command-line>:0:20: warning: ISO C99 requires whitespace after the macro name
[ 0%] Linking CXX static library libgmock_main.a
[ 0%] Built target gmock_main

等等。在整个项目的每个文件被编译到 100% 之间总是有这个警告。这只是编译的开始,它从谷歌测试库开始,但我并不特别怀疑它是错误宏的来源。 (但它可能是)这很奇怪,因为当我用谷歌搜索这个警告时,人们得到了代码和宏的快照,但我的编译器没有这样做,我只得到警告。

我在 Debian 上使用带有 gnu 编译器和 cmake 的 CLion。我尝试了多个正则表达式来查找没有空格的宏,但没有找到任何成功。我应该如何识别生成此警告的宏?

最佳答案

感谢@stefan 对我的问题的评论,从我的 CMakeLists.txt 文件中删除 2 个标志修复了这个问题。

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall -O0 -g -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_RULE_MESSAGES:BOOL=ON")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall -O0 -g")

我仔细检查并删除这些标志不会隐藏编译器警告,如未使用的变量等。不过我不确定删除这些标志会产生什么影响。

关于c++ - 找到有问题的宏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45944913/

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