小编Imm*_*lPC的帖子

带有 g++ -O2 ( 或 -Os, -O, -O1, ... ) 的模板警告

我收到一些模板和 g++ -Os 的警告。为什么 ?如何使用 -Os -Winline 删除这些警告?

编辑1:G ++ v4.6.1如果我更换uint32_t的无符号整型我的主要错误被纠正:(此bug已报道:http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52888

Event.h:109:12: attention : inlining failed in call to ‘uint32_t Event<ParamT>::attach(ListenerT*, bool (ListenerT::*)(ParamT)) [with ListenerT = Listener, ParamT = unsigned int, uint32_t = unsigned int]’: mismatched arguments [-Winline]
Run Code Online (Sandbox Code Playgroud)

编辑 2:以下警告似乎是 g++ 错误(http://gcc.gnu.org/ml/gcc-help/2012-07/msg00029.html)(我没有任何 ~Player() )inlining failed in call to ‘Player::~Player()’: call is unlikely and code size would grow [-Winline]

编辑 3:要删除以前的警告,请添加Player::~Player() __attribute__ ((noinline)) {}

.

测试代码:Event.h

#ifndef …
Run Code Online (Sandbox Code Playgroud)

c++ optimization events templates warnings

1
推荐指数
1
解决办法
960
查看次数

标签 统计

c++ ×1

events ×1

optimization ×1

templates ×1

warnings ×1