[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Warning with clang, error with gcc : attached files

From: David Chisnall
Subject: Re: Warning with clang, error with gcc : attached files
Date: Fri, 3 May 2019 14:11:04 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

On 03/05/2019 14:05, Fred Kiefer wrote:
Thanks !  I feared it was too simple. So I still get the same problem : the 
error in gcc does seem to come from the fact that [self  themeControlState] 
returns an id (because private) when GSThemeControlState is an enum and not a 
When I tried declare a category of NSButtonCell  to have this function public, 
I thought I could use a selector to perform the call . But I still get the same 
problem now : how will I have a return value that is for sure a 
GSThemeControlState ?

Why would you use the selector if you already declared a category. Just having 
a category and using the method normally in the file should work.

I believe the confusion is that we are suggesting that you *declare* a category, not *implement* a category.

If you have a class A with a header like this:

@interface A : B
- (void)foo;

And a .m file that contains this:

@implementation A
- (void)foo {}
- (int)bar { return 42; }

You can add a category *declaration* in another file like this:

@interface A (SecretStuff)
- (int)bar;

This tells the compiler that you expect A to implement a method called bar that takes no arguments and returns int. If you then call it and it does not exist, you will get an exception. If you call it and the return types / argument types don't match then the GNUstep runtime will either raise an exception or warn you (depending on how you've configured it), other runtimes will do unexpected things up to and including corrupting your stack.

You don't need to provide an @implementation for this category, the compiler assumes that one exists in another compilation unit.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]