??????C++??????????????????
???????????? ???????[ 2016/1/11 11:30:40 ] ??????????????????? .NET
??????????????????????????????????????????????PVS-Studio ????????? C/C++ ????????????????????????? 200 ??? C/C++ ?????????????? Unreal Engine??Php??Haiku??Qt ?? Linux ?????????????????????????????????????????????????顣?????????????????????????У????????
??????????? Bug ???? Source SDK ????????з?????
???????????
??????????????????????????????????????????С???????????????????????????????????
enum PhysGunPickup_t
{
PICKED_UP_BY_CANNON??
PUNTED_BY_CANNON??
PICKED_UP_BY_PLAYER??
};
enum PhysGunDrop_t
{
DROPPED_BY_PLAYER??
THROWN_BY_PLAYER??
DROPPED_BY_CANNON??
LAUNCHED_BY_CANNON??
};
void CBreakableProp::OnPhysGunDrop(....?? PhysGunDrop_t Reason)
{
....
if( Reason == PUNTED_BY_CANNON )
{
PlayPuntSound();
}
....
}
?????????
????Reason ????????????????? PhysGunDrop_t??????????????????????????????????????????????????????
???????????? bug ??????飬?????????? Clang??TortoiseGit ?? Linux Kernel ????????ж???????????
????????????????????????C++?У????????????????????????????????????????????????????????
???????????
?????????????δ????????汾????????????????? PUNTED_BY_CANNON ????? DROPPED_BY_CANNON ???? LAUNCHED_BY_CANNON ???????????? LAUNCHED_BY_CANNON ?????????
????if( Reason == LAUNCHED_BY_CANNON )
????{
????PlayPuntSound();
????}
???????飺
?????????????C++д?????????????????bug??????????????????????????????????????“?????”??
????????C++11?е??Щ??????????????????????auto?????????????????????????????????к??????? ????????????????д????????????????????????????????????????????????????? C?????У? ???б?????????????????????????????????????м?????β????????????????????????Alice????????????????????????????????????淶????????????? ???磬????????PfAlice????????????????
????C++???????????????????????????????????????????????????????????????????????auto????????????????3????????????????????????????????? ???? auto Alice= FOO(); ????? Alice?????TM??Alice?????????????????????????в???????
??????????????????????????? ?????????????Щ?μ????????????????????? ???????“?????”?? ???????????а????????????
?????????????????????????????????????????????????????????????г????????????????o????????£?
enum class PhysGunDrop_t
{
DROPPED_BY_PLAYER??
THROWN_BY_PLAYER??
DROPPED_BY_CANNON??
LAUNCHED_BY_CANNON??
};
void CBreakableProp::OnPhysGunDrop(....?? PhysGunDrop_t Reason)
{
....
if( Reason == PhysGunDrop_t::LAUNCHED_BY_CANNON )
{
PlayPuntSound();
}
....
}
??????????????????????????????????????????????????????????????????????????????????檔
????????????????????????????ж?????壬??????Щ?????????ο???????????????????C++11???????????????????????
????Wikipedia. C++11. Strongly typed enumerations.
????Cppreference. Enumeration declaration.
????StackOverflow. Why is enum class preferred over plain enum?
??????????????t????????????? PVS-Studio ????????????????V556 ????????????????б???Reason == PUNTED_BY_CANNON??
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11