C / C++ compiler warnings: do you clean up all your code to remove them or leave them in?

前端 未结 18 2324
夕颜
夕颜 2020-12-24 00:08

I\'ve worked on many projects where I\'ve been given code by others to update. More often than not I compile it and get about 1,000+ compiler warnings. When I see compiler w

18条回答
  •  孤城傲影
    2020-12-24 01:12

    Clean them up if possible. On a multi-platform/multi-compiler codebase (I've worked on one that compiled on 7 different OSs with 6 different compilers) that's not always possible though. I've seen cases where the compiler is just wrong (HP-UX aCC on Itanium, I'm looking at you), but that's admittedly rare. As others note, you can disable the warning in such a situation.

    Many times what's a warning in this version of the compiler may become an error in the next version (anyone upgrading from gcc 3.x to 4.x should be familiar with that), so clean it up now.

    Some compilers will emit really useful warnings that will become problems under certain circumstances -- Visual C++ 2005 and 2008 can warn you about 64-bit issues, which is a HUGE benefit nowadays. If you have any plans to migrate to 64-bit, just cleaning up those kinds of warnings will dramatically reduce your port time.

提交回复
热议问题