C++ 遇到的bug,自己的问题,交叉引用了

在开发过程中,面对复杂文件依赖关系,调试bug时可能会陷入文件循环导入的困境。本文分享了一个实例,从配置文件导入顺序出发,通过打断循环依赖链成功定位并修复了问题。此过程不仅锻炼了开发者对代码结构的理解,也强调了清晰的文件组织和导入顺序的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

心情难以平静,调bug调了一天。

Compiling chatserver ../Src/config_redis.cpp          -----------------------------------------------------0
g++  -c -w -D__cplusplus -pthread -fshort-wchar  -fPIC -rdynamic -w -O3  -DTRACE_LOG -DNDEBUG -D__SERVER -DUNICODE -I../../../Include  -I../Src  -L../../../lib -L../../../product_l../Src/config_redis.cpp -o ../Src/config_redis.o 
In file included from ../Src/stdafx.h:42,                          ----------------------------------------------------1
                  from ../Src/config_redis.h:4,                         ------------------------------------------------------2
                 from ../Src/config_redis.cpp:1:                      ------------------------------------------------------3


../Src/GlobalResource.h:39: 错误:‘CConfigRedis’没有命名一个类型
make: *** [../Src/config_redis.o] 错误 1




编译程序遇到了如上程序,找bug找了一天,开始以为是不是CConfigRedis的类定义没有被引用进来,各种找,后来大神一句话指点了一下。终于发现了bug。


发现了没,include    (0->1->2->3 )  了一圈啊。所以找到某个文件把这个环断掉就好了。

D:\STM32CUBECLT\CMake\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=D:/STM32CUBECLT/Ninja/bin/ninja.exe -DCMAKE_C_COMPILER=D:/STM32CUBECLT/GNU-tools-for-STM32/bin/arm-none-eabi-gcc.exe -DCMAKE_CXX_COMPILER=D:/STM32CUBECLT/GNU-tools-for-STM32/bin/arm-none-eabi-c++.exe -G Ninja -S D:\el\1231123213\MDK-ARM\stm32\xuexi -B D:\el\1231123213\MDK-ARM\stm32\xuexi\cmake-build-debug -- The C compiler identification is GNU 13.3.1 -- The CXX compiler identification is GNU 13.3.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - failed -- Check for working C compiler: D:/STM32CUBECLT/GNU-tools-for-STM32/bin/arm-none-eabi-gcc.exe -- Check for working C compiler: D:/STM32CUBECLT/GNU-tools-for-STM32/bin/arm-none-eabi-gcc.exe - broken CMake Error at D:/STM32CUBECLT/CMake/share/cmake-3.28/Modules/CMakeTestCCompiler.cmake:67 (message): The C compiler "D:/STM32CUBECLT/GNU-tools-for-STM32/bin/arm-none-eabi-gcc.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: 'D:/el/1231123213/MDK-ARM/stm32/xuexi/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-s6c5qr' Run Build Command(s): D:/STM32CUBECLT/Ninja/bin/ninja.exe -v cmTC_fb1bb [1/2] D:\STM32CUBECLT\GNU-tools-for-STM32\bin\arm-none-eabi-gcc.exe -std=gnu11 -fdiagnostics-color=always -o CMakeFiles/cmTC_fb1bb.dir/testCCompiler.c.obj -c D:/el/1231123213/MDK-ARM/stm32/xuexi/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-s6c5qr/testCCompiler.c [2/2] C:\WINDOWS\system32\cmd.exe /C "cd . && D:\STM32CUBECLT\GNU-tools-for-STM32\bin\arm-none-eabi-gcc.exe CMakeFiles/cmTC_fb1bb.dir/testCCompiler.c.obj -o cmTC_fb1bb.exe -Wl,--out-implib,libcmTC_fb1bb.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." FAILED: cmTC_fb1bb.exe C:\WINDOWS\system32\cmd.exe /C "cd . && D:\STM32CUBECLT\GNU-tools-for-STM32\bin\arm-none-eabi-gcc.exe CMakeFiles/cmTC_fb1bb.dir/testCCompiler.c.obj -o cmTC_fb1bb.exe -Wl,--out-implib,libcmTC_fb1bb.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." Cannot create temporary file in C:\Users\张宇鹏\AppData\Local\Temp\: No such file or directory arm-none-eabi-gcc.exe: internal compiler error: Aborted signal terminated program collect2 Please submit a full bug report, with preprocessed source (by using -freport-bug). See <https://gcc.gnu.org/bugs/> for instructions. ninja: build stopped: subcommand failed. CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:28 (project) -- Configuring incomplete, errors occurred! [已完成] 请告诉我发生的情况,并告诉我怎么解决
最新发布
07-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值