Why would you declare variables in the middle of defining a function?

后端 未结 2 1780
鱼传尺愫
鱼传尺愫 2021-01-29 02:49

I have to modify the code for the G722 codec made by the ITU at work.

I contains realy funky function definitions like this one :

    int 
    main (argc         


        
2条回答
  •  春和景丽
    2021-01-29 03:47

    That's very old (pre-1989 standard) function definition syntax. It's still legal for backwards-compatibility's sake, but it's definitely no longer recommended.

    As to why anyone would use it, the only reasonable scenarios I can think of are:

    • this code is very old and nobody wants to risk breaking it just to bring it up to date;
    • it's hosted on a platform for which compilers for later versions of the language were never implemented;

提交回复
热议问题