This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

libobjc: @protocol doesn't retrieve valid class pointer



When I create an instance of my protocol using the statement
@protocol(TestProtocol), I can't invoke any method of it. As I ran
through the code using gdb, I found out, that the class pointer of this
structure is not set correctly.
However, if I have an implementation of the protocol inside the same
bundle, the problem doesn't occur.


Michael



#include <Foundation/Foundation.h>

@protocol TestProtocol
- (void) doSomething;
@end

/** Code crashes without this implementation
@interface Test : NSObject <TestProtocol>
@end

@implementation Test

- (void) doSomething
{
  printf("Did Something\n");
}

@end
**/

int main(int argc, char* argv[])
{
  Protocol *pr;

  pr = @protocol(TestProtocol);

  printf("Protocol name: %s\n", [pr name]);

  return 0;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]