Confusing @import warning

24 views
Skip to first unread message

Simon

unread,
Aug 12, 2016, 6:29:24 PM8/12/16
to Cappuccino & Objective-J
Hi all,

So I have a class (IBoxComponentEditView) that contains a specialized CPView defined in IBoxButton.j in the same directory. At the top of IBoxComponentEditView I have:

@import "../Constants.j"
@import "../Protocols.j"
@import "IBoxButton.j"

IBoxButton.j defines IBoxButton, vis:

 
 @implementation IBoxButton : CPView
{
...
}

... and inside IBoxComponentEditView.j, there's a call to create an IBoxButton:

var btn = [[IBoxButton alloc] initWithFrame:f andContent:@"Delete"];


All well and good, it's the same sort of code I've used a thousand times, but this time in the console window, I'm seeing:

var btn = [[IBoxButton alloc] initWithFrame:f andContent:@"Delete"];
              ^
WARNING line 95 in http://server/Classes/UI/Box/IBoxComponentEditView.j: Using unknown class or uninitialized global variable 'IBoxButton'

... which is difficult to believe, given the @import is right there at the top of the file. Even more confusing, if I ignore the warning, go ahead and click through the UI to exercise the code, the button is rendered correctly and appears in the correct place etc.

So, am I "lucking out" and there's a genuine error here, or is the compiler just confused and I can ignore it ? Anyone with the "wisdom of ages" want to chime in ?

Cheers
   Simon

Antoine Mercadal

unread,
Aug 12, 2016, 7:37:11 PM8/12/16
to objec...@googlegroups.com
Hey

There are some weird stuff happening sometimes with the dep maps. It can also happens because you have cyclic imports  somewhere. 

If you can't find out where, just add a @class IBoxButton and it will stop complaining. That won't cause any issue as all classes are available in the global scope anyway in the end. 

Another practice I ended up doing is only using @import for the inherited classes and only @class for the other ones, then have general imports files in each folder. That also fixed a lot of stupid random errors that happened while jake deploying very large codebase. 

Thanks

-- 
Antoine Mercadal
--
You received this message because you are subscribed to the Google Groups "Cappuccino & Objective-J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectivej+...@googlegroups.com.
To post to this group, send email to objec...@googlegroups.com.
Visit this group at https://groups.google.com/group/objectivej.
For more options, visit https://groups.google.com/d/optout.

Simon

unread,
Aug 13, 2016, 12:49:43 AM8/13/16
to Cappuccino & Objective-J


On Friday, August 12, 2016 at 4:37:11 PM UTC-7, Antoine Mercadal wrote:
Hey

There are some weird stuff happening sometimes with the dep maps. It can also happens because you have cyclic imports  somewhere. 

If you can't find out where, just add a @class IBoxButton and it will stop complaining. That won't cause any issue as all classes are available in the global scope anyway in the end. 

Another practice I ended up doing is only using @import for the inherited classes and only @class for the other ones, then have general imports files in each folder. That also fixed a lot of stupid random errors that happened while jake deploying very large codebase. 

Cheers :) 

It started doing some pretty weird things - buttons that would sometimes work, sometimes not, that sort of thing. In the end I just ditched the class causing the problems and solved the issue in a different way. I get a nice fade-in/fade-out effect doing it this new way, so there's the silver lining :)

Good to know about the @class thing :)

Thanks again,

Simon
Reply all
Reply to author
Forward
0 new messages