Using the GCC/G++ compiler, I've used the following code structure for a long time and never had any problem with it:
if((int returnCode = function(argument1, argument2)) != 0) {
manageTheError(returnCode);
}
I switched to Visual C++ 2015, but now my code throws many errors everytime I use this structure: (translated from french)
Syntax error: missing ')' before identifier 'returnCode' (line 1)
'returnCode': undeclared identifier (line 1)
Syntax error: '!=' (line 1)
Syntax error: ')' (line 1)
Syntax error: missing ';' before '{' (line 1)
')' was expected (line 1)
expression was expected (line 1)
'returnCode': undeclared identifier (line 2)
identifier 'returnCode' undefined (line 2)
As this question explains, my code structure is wrong and should not be used. But why does GCC/G++ accept it without complaining (not even a warning) and how does it manage these structures?