description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ||
---|---|---|---|---|---|---|---|
Learn more about: Compiler Error C2561 | Compiler Error C2561 | 11/04/2016 |
|
| 0abe955b-53a6-4a3c-8362-b1a8eb40e8d1 |
'identifier' : function must return a value
The function was declared as returning a value, but the function definition does not contain a return
statement.
This error can be caused by an incorrect function prototype:
If the function does not return a value, declare the function with return type void.
Check that all possible branches of the function return a value of the type declared in the prototype.
C++ functions containing inline assembly routines that store the return value in the
AX
register may need a return statement. Copy the value inAX
to a temporary variable and return that variable from the function.
The following sample generates C2561:
// C2561.cppintTest(int x) { if (x) { return; // C2561// try the following line instead// return 1; } return0; } intmain() { Test(1); }