Date
1 - 7 of 7
Declaring a method as 'noreturn'
Carl Hoefs
Xcode 11.3.1
What is the syntax to declare an Objc method as 'noreturn'? I can't find any documentation on it anywhere. ∙ Xcode: Method 'providerCV06' could be declared with attribute 'noreturn' -Carl
|
|
Alex Zavatone
https://stackoverflow.com/questions/36346451/clang-warning-in-dubious-case-function-foo-could-be-declared-with-attribute
toggle quoted messageShow quoted text
https://www.qtcentre.org/threads/70260-How-to-declare-attribute-noreturn Just google the error message and you’ll see the results that others have run into. I think there might be a working answer in there. Cheers, Alex Zavatone
On Aug 12, 2020, at 5:57 PM, Carl Hoefs <newslists@autonomy.caltech.edu> wrote:
|
|
__attribute((noreturn)) It should work if placed right before the ";" in the @interface. —Jens
|
|
Alex Zavatone
Carl, that error message isn’t in the code I sent you, is it? If to, I’ll just send you the class and you can modify it to your liking. I just copied and pasted in the code from a working class, and it might be incomplete.
toggle quoted messageShow quoted text
|
|
Carl Hoefs
Jens,
toggle quoted messageShow quoted text
Yes, that works! A bit unintuitive ;-) but it works! - (void)providerCV06 __attribute((noreturn)); Many thanks! -Carl
|
|
Are you sure `noreturn` is appropriate there? I mean, the name "providerCV06" kind of sounds like it actually does something. A `noreturn` function literally never returns, i.e. it either throws an exception or kills the process … is that what you intend? This is significant because the compiler can and does optimize around this — it can omit a jump after a call to a `noreturn` function because it knows it'll never be reached. If a function marked `noreturn` actually does return, it can cause incorrect behavior. —Jens
|
|
Carl Hoefs
Thanks for the addt'l info. Note that it's only a stub method, to be replaced with one provided by a 3rd party. I wanted to quiet the 'noreturn' warning mostly out of curiosity, since I had never seen such a message before. It's not intended to end up in the delivered product.
toggle quoted messageShow quoted text
-Carl
|
|