I did a bunch of C++ programming back in the 1980s and early 90s, but not much since. In trying to program a CoreAudio application, about 10 years ago I found the sample below, and was able to use and compile it. But now it won't compile, complaining about the undeclared identifier "home". This seems to be some sort of a "go to" tag with which I'm not familiar. I guess it was legal 10 years ago but it's not now, and I don't even know what name to call it so that I can search for help about it. In the code below, it looks like the function require_noerr executes another function and, if there's an error, it jumps to the "home" tag at the end. Can anyone shed light on this construct? Is there a way to make this work? (And yes, I'm flying blind with CoreAudio just trying to make something simple work...)
It's a label, which is used with goto.
Generally, the use of goto is considered a bad practice, although I have seen it in places where there's a lot of branching paths, but some sort of cleanup that needs to happen before a function returns.
The require_noerr basically has to be a macro for this to compile, because a label cannot be a function parameter.
If you search the web for require_noerr, you'll find similar issues people have had. Apparently, the require_noerr macro has changed for newer Apple systems, and has broken backwards compatibility.
Thanks! Yes, I'm old enough to have read "Goto considered harmful", so I was surprised that this looked like that. I guess this is an alternative to the use of "break" to get to a recovery point. I did find that the "standard" syntax of changed, as you mention, and I was able to get this old code to compile by editing to include the leading spaces. Many thanks!