这个问题在这里已经有了答案:CanItellthecompilertoconsideracontrolpathclosedwithregardstoreturnvalue?(3个答案)关闭去年。当调用总是从返回值的函数中抛出异常的函数时,编译器通常会警告并非所有控制路径都返回值。合法地如此。voidAlwaysThrows(){throw"something";}boolfoo(){if(cond)AlwaysThrows();elsereturntrue;//WarningC4715here}有没有办法告诉编译器AlwaysThrows按照它说的去做?我知道我可以在函数调用后添加另一