main.exe flag redefined:graceful

本文探讨了一个关于 Go 语言中 Goroutine 运行时出现的异常情况,通过一个具体的例子,分析了该问题产生的原因,即不同项目间日志包的不当引用导致的冲突。

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

goroutine 1 [running]:
flag.(*FlagSet).Var(0xc042032120, 0xcd0960, 0xd33499, 0xa07f57, 0x8, 0xa1959f, 0x21)
        D:/ITsoftware/golang/go/src/flag/flag.go:793 +0x5e8
flag.BoolVar(0xd33499, 0xa07f57, 0x8, 0xc0420eb000, 0xa1959f, 0x21)
        D:/ITsoftware/golang/go/src/flag/flag.go:572 +0x79
git.benbentest.com/vendor/github.com/astaxie/beego/grace.init.0()
D:/gopath/src/git.benbentest.com/vendor/github.com/astaxie/beego/grace/grace.go:93 +0x67
git.benbentest.com/vendor/github.com/astaxie/beego/grace.init()
        <autogenerated>:1 +0x9a
git.benbentest.com/vendor/github.com/astaxie/beego.init()
        <autogenerated>:1 +0x7a
git.benbentest.com/log.init()
        <autogenerated>:1 +0x55
main.init()
        <autogenerated>:1 +0x69
这个问题出现的具体原因可能有多种,没做深入探究,只说我出现的原因,给大家点思路:假设有A、B两个项目,都使用beego框架。分别对这两个项目日志做了处理,放在log包中。由于不小心,在A项目中引用了B项目中的log包,就出现了上面的问题。因此出现类似的问题,可能是由于相同文件包的混用导致。
---Preprocess Failed--- In file included from E:/code/Components/PduR/Source\PduR_Instance.h:54:0, from E:/code/Components/PduR/Source\PduR.c:262, from vcast_preprocess.57460.0.c:3: E:\CODE\COMPONENTS\PDUR\CONFIG\Template/PduR_Cfg.h:735:0: warning: "PDUR_DIAG_PATH_CNT" redefined #define PDUR_DIAG_PATH_CNT (0U)</N> E:\CODE\COMPONENTS\PDUR\CONFIG\Template/PduR_Cfg.h:717:0: note: this is the location of the previous definition #define PDUR_DIAG_PATH_CNT E:\CODE\COMPONENTS\PDUR\CONFIG\Template/PduR_Cfg.h:784:14: warning: extra tokens at end of #ifndef directive #ifndef PDUR_</FUNC:UPPER($BswModule)/>_H_ ^ E:\CODE\COMPONENTS\PDUR\CONFIG\Template/PduR_Cfg.h:785:14: warning: ISO C99 requires whitespace after the macro name #define PDUR_</FUNC:UPPER($BswModule)/>_H_ ^ In file included from E:/code/Components/PduR/Source\PduR.c:262:0, from vcast_preprocess.57460.0.c:3: E:/code/Components/PduR/Source\PduR_Instance.h:61:28: error: operator '>' has no left operand #if (PDUR_MAX_INSTANCE_CNT > 1U) ^ In file included from E:/code/Components/PduR/Source\PduR.c:262:0, from vcast_preprocess.57460.0.c:3: E:/code/Components/PduR/Source\PduR_Instance.h:111:28: error: operator '>' has no left operand #if (PDUR_MAX_INSTANCE_CNT > 1U) ^ In file included from E:/code/Components/PduR/Source\PduR.c:263:0, from vcast_preprocess.57460.0.c:3: E:/code/Components/PduR/Source\PduR_Channel.h:55:28: error: operator '>' has no left operand #if (PDUR_MAX_INSTANCE_CNT > 1U) ^ In file included from E:/code/Components/PduR/Source\PduR.c:264:0, from vcast_preprocess.57460.0.c:3: E:/code/Components/PduR/Source\PduR_Protocol.h:44:27: error: operator '>' has no left operand #if PDUR_MAX_INSTANCE_CNT > 1U ^ In file included from E:/code/Components/PduR
最新发布
04-02
g++ snake.cpp -o snake -lncurses snake.cpp:7:0: warning: "KEY_UP" redefined [enabled by default] #define KEY_UP 65 ^ In file included from snake.cpp:1:0: /usr/include/curses.h:1410:0: note: this is the location of the previous definition #define KEY_UP 0403 /* up-arrow key */ ^ snake.cpp:8:0: warning: "KEY_DOWN" redefined [enabled by default] #define KEY_DOWN 66 ^ In file included from snake.cpp:1:0: /usr/include/curses.h:1409:0: note: this is the location of the previous definition #define KEY_DOWN 0402 /* down-arrow key */ ^ snake.cpp:9:0: warning: "KEY_RIGHT" redefined [enabled by default] #define KEY_RIGHT 67 ^ In file included from snake.cpp:1:0: /usr/include/curses.h:1412:0: note: this is the location of the previous definition #define KEY_RIGHT 0405 /* right-arrow key */ ^ snake.cpp:10:0: warning: "KEY_LEFT" redefined [enabled by default] #define KEY_LEFT 68 ^ In file included from snake.cpp:1:0: /usr/include/curses.h:1411:0: note: this is the location of the previous definition #define KEY_LEFT 0404 /* left-arrow key */ ^ snake.cpp: In member function ‘void SnakeGame::generate_food()’: snake.cpp:25:23: error: ISO C++ forbids declaration of ‘p’ with no type [-fpermissive] for(auto& p : snake) ^ snake.cpp:25:27: error: range-based ‘for’ loops are not allowed in C++98 mode for(auto& p : snake) ^ snake.cpp:26:22: error: request for member ‘x’ in ‘p’, which is of non-class type ‘int’ if(p.x == food.x && p.y == food.y) continue; ^ snake.cpp:26:39: error: request for member ‘y’ in ‘p’, which is of non-class type ‘int’ if(p.x == food.x && p.y == food.y) continue; ^ snake.cpp: In constructor ‘SnakeGame::SnakeGame()’: snake.cpp:33:20: error: ‘nullptr’ was not declared in this scope srand(time(nullptr)); ^ snake.cpp:34:24: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default] snake.push_back({LINES/2, COLS/2}); ^ snake.cpp:34:42: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default] snake.push_back({LINES/2, COLS/2}); ^ snake.cpp: In member function ‘void SnakeGame::update()’: snake.cpp:69:19: error: ISO C++ forbids declaration of ‘p’ with no type [-fpermissive] for(auto& p : snake) ^ snake.cpp:69:23: error: range-based ‘for’ loops are not allowed in C++98 mode for(auto& p : snake) ^ snake.cpp:70:18: error: request for member ‘x’ in ‘p’, which is of non-class type ‘int’ if(p.x == head.x && p.y == head.y) { ^ snake.cpp:70:35: error: request for member ‘y’ in ‘p’, which is of non-class type ‘int’ if(p.x == head.x && p.y == head.y) { ^ snake.cpp: In member function ‘void SnakeGame::draw()’: snake.cpp:93:19: error: ISO C++ forbids declaration of ‘p’ with no type [-fpermissive] for(auto& p : snake) ^ snake.cpp:93:23: error: range-based ‘for’ loops are not allowed in C++98 mode for(auto& p : snake) ^ In file included from snake.cpp:1:0: snake.cpp:94:23: error: request for member ‘x’ in ‘p’, which is of non-class type ‘int’ mvaddch(p.x, p.y, '*'); ^ snake.cpp:94:28: error: request for member ‘y’ in ‘p’, which is of non-class type ‘int’ mvaddch(p.x, p.y, '*'); ^ snake.cpp: In function ‘int main()’: snake.cpp:124:49: error: ‘class SnakeGame’ has no member named ‘get_score’ printf("Game Over! Final Score: %d\n", game.get_score()); ^ [root@localhost ~]#
03-25
PS C:\Users\15330\Desktop\ui界面测试> pylint mandala_tesk_2.py ************* Module mandala_tesk_2 mandala_tesk_2.py:43:0: C0303: Trailing whitespace (trailing-whitespace) mandala_tesk_2.py:50:0: C0303: Trailing whitespace (trailing-whitespace) mandala_tesk_2.py:1:0: C0114: Missing module docstring (missing-module-docstring) mandala_tesk_2.py:4:0: C0116: Missing function or method docstring (missing-function-docstring) mandala_tesk_2.py:4:15: W0621: Redefining name 'center' from outer scope (line 142) (redefined-outer-name) mandala_tesk_2.py:13:0: C0116: Missing function or method docstring (missing-function-docstring) mandala_tesk_2.py:13:23: W0621: Redefining name 'center' from outer scope (line 142) (redefined-outer-name) mandala_tesk_2.py:20:0: C0116: Missing function or method docstring (missing-function-docstring) mandala_tesk_2.py:20:28: C0103: Argument name "R" doesn't conform to snake_case naming style (invalid-name) mandala_tesk_2.py:20:0: R0913: Too many arguments (6/5) (too-many-arguments) mandala_tesk_2.py:20:0: R0917: Too many positional arguments (6/5) (too-many-positional-arguments) mandala_tesk_2.py:20:20: W0621: Redefining name 'center' from outer scope (line 142) (redefined-outer-name) mandala_tesk_2.py:20:28: W0621: Redefining name 'R' from outer scope (line 143) (redefined-outer-name) mandala_tesk_2.py:20:31: W0621: Redefining name 'r' from outer scope (line 144) (redefined-outer-name) mandala_tesk_2.py:20:34: W0621: Redefining name 'n' from outer scope
03-13
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值