Undeclared variable from base class when derived class has property

I have the following code below, where a base class has a member which is (should be) accessible by a derived class.

The code below however gives a compilation error ...abcAppDelegate.m:30: error: 'baseVal_' undeclared (first use in this function)

If I call the variable using self->baseVal_ or if I remove the property defined in the derived class then everything is ok.

Also, if I define a category of the derived class, then I can access baseVal_ without error.

//---------------------------------------------------------------
// BASE CLASS
//---------------------------------------------------------------

@interface BaseClass : NSObject 
{
@protected    
    BOOL baseVal_;
} 
@end

@implementation BaseClass 
@end

//---------------------------------------------------------------
// DERIVED CLASS
//---------------------------------------------------------------

@interface DerivedClass : BaseClass {
} 
@property (readwrite) BOOL val;
@end

@implementation DerivedClass
@synthesize val;
- (void) foo {
    baseVal_ = YES;
}
@end

Answers


Have a look here: Click. Seems to possibly be a bug with GCC, but it's easily fixable by adding val as an instance variable instead of using the property without.


Need Your Help

Using eq_ with nose tests, is there a way to know which line # and position # two strings differ?

python pycharm nosetests

Coming from some other technologies, there have been string comparison assertions for use in unit tests that show string 1 on one line (in the console output) and string 2 on the second line, and c...

Killing Root Processes in Android

android service process su pppd

I'm building an Android application that starts a process by calling su and sending it a command, along these lines:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.