Why should I always enable compiler warnings?

后端 未结 20 1597
时光说笑
时光说笑 2020-11-22 00:28

I often hear that when compiling C and C++ programs I should \"always enable compiler warnings\". Why is this necessary? How do I do that?

Sometimes I also hear tha

20条回答
  •  情深已故
    2020-11-22 01:07

    I once worked for a large (Fortune 50) company that manufactured electronic testing equipment.

    The core product of my group was an MFC program that, over the years, came to generate literally hundreds of warnings. Which were ignored in almost all cases.

    This is a frigging nightmare when bugs occur.

    After that position, I was lucky enough to be hired as the first developer in a new startup.

    I encouraged a 'no warning' policy for all builds, with compiler warning levels set to be pretty noisy.

    Our practice was to use #pragma warning - push/disable/pop for code that the developer was sure was really fine, along with a log statement at the debug level, just in case.

    This practice worked well for us.

提交回复
热议问题