http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49301

Nicola Pero <nicola at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nicola at gcc dot gnu.org

--- Comment #3 from Nicola Pero <nicola at gcc dot gnu.org> 2011-06-06 15:51:27 
UTC ---

> But could we turn it off with some flag?

Not at the moment.  We could add a flag to turn it off if there are enough
important examples.


> And also, in my example, the interface is just BELOW! I think GCC should first
> look further… just a thought.

:-)


> So in programming it must be like this:
>
> The header file has a @class, so the class can be used for variables and 
> method arguments.

Yes, header files can use @class to refer to classes defined in other headers
and prevent recursive class definitions.  Eg, the header B.h could be:

@class A;

@interface B
- (A *)giveMeA;
@end

and the header A.h could be:

@class B;
@interface A
- (B *)giveMeB;
@end

the two headers are now independent and you can include them independently
with no recursion.


> The method file should have the actual import of the interface, so the 
> messages are known, and no recursive import occurs?

Yes, the implementation generally should include full @interfaces for all
the classes that are involved in messaging ... so that the compiler can do
the checks.  In the example above, in A.m you would do

#import "A.h"
#import "B.h"

@implementation A
- (B *) giveMeB
{
   ...
}
@end

and similarly in the implementation of B.  No recursive @interface definitions
would occur, and the actual Objective-C code ("..." in the example) has the
full
@interfaces for all the classes and can do full type-checking. :-)

You could also a general header that #imports both A.h and B.h, and #import
that one instead.

Thanks

Reply via email to