c - Is commenting out a #include a safe way to see if it's unneeded? -


i keep files clean, prefer take out includes don't need. lately i've been commenting includes out , seeing if compiles without warnings (-wall -wextra -pedantic, minus couple specific ones). figure if compiles without warnings didn't need it.

is safe way check if include needed or can introduce ub or other problems? there specific warnings need sure enabled catch potential problems?

n.b. i'm using objective c , clang, specific appreciated, given flexibility of objective c think if there's trouble general c thing. problems in c affect objective c.

in principle, yes.

the exception if 2 headers interact in hidden way. say, if you:

  • include 2 different headers define same symbol differently,
  • both definitions syntactically valid , well-typed,
  • but 1 definition good, other breaks program @ run-time.

hopefully, header files not structured that. it's unlikely, though not inconceivable.

i'd more comfortable doing if had (unit) tests.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -