Return value from local scope?

后端 未结 6 1015
终归单人心
终归单人心 2021-01-05 11:06

Bumped into some code like this in our code base... which made me worried.

int foo(int a); // Forward declaration.

int baz() {
    int result = {
         i         


        
6条回答
  •  不知归路
    2021-01-05 11:22

    I do not know of a single compiler that will accept that. Additionally, you'd be better off doing this:

    int foo();
    int dosomestuff();
    
    int baz()
    {
       int result = foo(dosomestuff()) ? 0 : -1;
       return result;
    }
    

提交回复
热议问题