Errors, bugs, questions - page 1643

 
A100:

Compile error: ')'. - not all control paths return a value

You don't have all branches of the code returning a value:

int f()
{
 int res = 0;
        while ( true ) //или for(;;)
        {
//много строк c return, continue, без break
                res = 0;break или continue
//много строк c return, continue, без break
                res = 1;break или continue 
        }
return(res);
}

Or like this:

int f()
{
        while ( true ) //или for(;;)
        {
//много строк c return, continue, без break
                return 0;
//много строк c return, continue, без break
                return 1;
        }
  return(значение возвращаемое по умолчанию если не выполнены предыдущее return);
}
 
Vitalii Ananev:

You don't have all branches of the code returning a value.

In his example, all of them do. You can only exit while(true) with break (which it does not have) or return.
 
Sergei Vladimirov:
In the example he gives, all of them. The only way to exit while(true) is with break (which he doesn't have) or return.
I'm not going to argue. But the compiler's error message ')' - not all the control paths return a value, says otherwise.
 
Vitalii Ananev:
I'm not going to argue. But the compiler error message ')' - not all control paths return a value, says otherwise.
Try the same thing in C++
 
A100:
Try the same thing in C++

What does C++ have to do with it?

....

Looked at your code more closely. You missed a mistake: the return value by the operator return should be written in brackets. return(0) but you wrote return 0;

 
Vitalii Ananev:

What does C++ have to do with it?

Moreover, C++ acts as a certain model in this case.
Vitalii Ananev:

Looked at your code more closely. You missed a mistake - the return value by return operator should be written in brackets. return(0) but you wrote return 0;

Why are there unnecessary brackets?
 
A100:
While C++ acts as a reference in this case

So you write in C++ and compile it all in mql?

Why the extra brackets?

This is the syntax of mql language.

 
Vitalii Ananev:

So you write in C++ and compile it all in mql?

This is the syntax of the mql language.

You can return a value without brackets. Just try it.
 
Artyom Trishkin:
You can return a value without brackets. Just try it.
Yes, it compiles, but I always write it with parentheses. It's already a habit that has become a rule.
 
Vitalii Ananev:

So you write in C++ and compile it all in mql?

This is the syntax of the mql language.

Have you come to us from the distant past? )
Reason: