c++ - is there any way to find unused defines and structs in make command -


i have huge project re-factoring, there lot of define statements changing enums, defines changing const variables in common file.

while re-factoring found of defines repeated in sub classes header. of defines, , structs not used, or used to.

how can make compiler point them out, when compiler show unused variables?

i want ride of them,

right comment them out, , find needed manually! there other ways

i hate #define contant in 1 big .h file too. ,i find way define contant c++ type system. work 2 year's ago.

------------------------------------------------------ id_system.h ------------------------------------------------------ #pragma once template<int n> struct id_factory{     enum {_id=n};     static const unsigned int m_duplicate_checker;  };  #define id_declare(classname, number) \ struct classname{ \     typedef id_factory<number> myid_type; \     static const unsigned int id; \ }; \ ------------------------------------------------------ a.h  ------------------------------------------------------ #pragma once #include "id_system.h" id_declare(wm_message_jj,1003) id_declare(wm_message_kk,1002) ------------------------------------------------------ b.h ------------------------------------------------------ #pragma once #include "id_system.h" id_declare(wm_message_pp,2013) id_declare(wm_message_tt,2014) id_declare(wm_message_vv,2015)  ------------------------------------------------------ id_system.cpp ------------------------------------------------------ #define id_checker(classname) \ const unsigned int classname::myid_type::m_duplicate_checker=classname::myid_type::_id; \ const unsigned int classname::id = classname::myid_type::m_duplicate_checker; \   #include "a.h" #include "b.h"  id_checker(wm_message_kk) id_checker(wm_message_jj) id_checker(wm_message_pp) id_checker(wm_message_tt) id_checker(wm_message_vv)  ------------------------------------------------------ main.cpp ------------------------------------------------------ #include "a.h" void main(){      int x = wm_message_kk::id;     int y = wm_message_jj::id; } 

advantage: 1) can detect duplicate id 2) client code (like main.cpp) need not include big .h file. 3) compile time reduced duo smallest dependence .h file


Comments