Search code examples
c++compiler-errorsreturn-path

Forcing an error when a function doesn't explicitly return a value on the deafult return path?


Is there a way, in VC++ (VSTS 2008), to froce a compiler error for functions that do not explicitly return a value on the default return path (Or any other quick way to locate them)?

On the same issue, is there any gaurentee as to what such functions actually return?


Solution

  • I don't know exactly the warning number, but you can use #pragma warning for enforcing a specific warning to be treated as error:

    Example:

    #pragma warning( error: 4001)
    

    will treat warning 4001 as error