Why MSVC generates warning C4127 when constant is used in “while” - C
问题 For code, while(1) { /* ..... */ } MSVC generates the following warning. warning C4127: conditional expression is constant MSDN page for the warning suggests to use for(;;) instead of while(1) . I am wondering what advantage for(;;) is giving and why it warns for the constant usage in while ? What flag should I use on GCC to get the same warning? 回答1: Constant conditionals are often enough simply bugs. Consider this: unsigned k; ... while (k>=0) { ... } The condition k>=0 would make sense if