How to get g++ to warn on unused member variables

前端 未结 3 1007
自闭症患者
自闭症患者 2021-02-12 23:29

g++ generates warnings for unused local variables. Is it possible to have g++ warn for unused class member variables and/or global variables?

class Obj {
 public         


        
3条回答
  •  花落未央
    2021-02-12 23:36

    I'm not aware of any such warning. Additionally I'll speculate that the reason it doesn't exist is because it can't be reliably generated in all cases, so they elected to not spend effort making it work for some subset of cases. For example, if the class friends another function that's in a library, the compiler would have no way of knowing if that library mutated any particular class attribute or not.

提交回复
热议问题