c++ - g++: Is there a way to warn if header file is not included in file? -
is there way compile source code g++, , have compiler warn me if have not included file in file should have?
for example, in large project quite easy write code in filea, uses function filec (which contains function declaration), forget add include statement. such error can hidden if filea includes file, fileb, fileb includes filec.
this compile without error, if code modified @ later date, , remove #include fileb.hpp filea, compilation fail, because forgot include filec many months ago!
is there compiler switch warn problem? similarly, there reverse switch, warn when #include unnecessary?
not answering question, using forward declarations , keeping includes in headers minimal might in avoiding such problems.
if use forward declarations in hpp files, independent each other, , forced include specific .hpp files each .cpp unit being compiled.
Comments
Post a Comment