GCC / G ++接受错误的代码结构

时间:2015-08-20 20:58:31

标签: c++ gcc compiler-errors visual-studio-2015

使用GCC / G ++编译器,我已经使用了以下代码结构很长时间,并且从未遇到任何问题:

if((int returnCode = function(argument1, argument2)) != 0) {
    manageTheError(returnCode);
}

我切换到Visual C ++ 2015,但现在我的代码每次使用此结构时都会抛出许多错误:(翻译自法语)

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)

正如this question所解释的那样,我的代码结构错误,不应该使用。但是为什么GCC / G ++接受它而不抱怨(甚至不是警告)以及它如何管理这些结构?

0 个答案:

没有答案