#import and PCH

Nicola Pero nicola@brainstorm.co.uk
Sat Jan 25 01:29:00 GMT 2003


> > Yes.  I'm looking at this, and I think the best thing is to have the 
> > Apple compiler look at inodes, and to remove #import altogether from 
> > the FSF.  Any objections?
> >
> I don't think we can go quite that fast - #import is an officially
> documented feature of Objective-C.  For instance, the ObjC reference
> that O'Reilly published last month recommends #import and doesn't
> say anything about it being deprecated.
> 
> I believe GNUstep decided to switch over to #include, but I'd like
> to check on that.  Assuming they have, then #import could be documented
> in 3.4 that it will be gone in 3.5.  Unlike some other features being
> proposed for removal, this one is still in active use today.

Yes - GNUstep is using #include and softly recommending #include instead
of #import to users, but - but our users are not necessarily doing what we
tell them, particularly if Apple is writing in all their `official' ObjC
doc that #import is the recommended way to include headers in ObjC. :-)

While I'm in favour of removing #import, I know it will definitely annoy
many GNUstep users (users which are just pure convinced GNU/FSF users) who
are using it - they *will* complain.

Personally, I'd strongly suggest to provide a handy replacement for
#import - I suggested in the past to give #pragma once an argument, and
identify files by the argument passed to #pragma once.

I'd even go as far as suggesting a new `#header XXX' directive for ObjC
only which does exactly the equivalent of `#pragma once XXX' (and which
basically, if put as the first thing in the file except comments, is
exactly equivalent to #ifndef XXX/#define XXX/.../#endif).

If you remove #import, users will complain, and when they get to me or to
you and complain, I/you need to have an answer ready for them.  A
replacement syntax, which gets a similar benefit of #import (which is
saving them the task of writing the #ifndef/#define/#endif), but which you
think is technically sound and correct, would be the best solution.  You
can tell them - #import has been deprecated in favour of the better
#header solution.

But probably not really a solution unless Apple commits to using it too.

Anyway - if you remove #import please allow for enough time for the users
to be aware of the impeding change, and for them to update all their
codebase.  First, ship a compiler with the -Wno-import flag disabled so
that nobody will be able to ignore the fact that #import is deprecated.  
Only then, ship a compiler with no #import.

It has been deprecated for years, but nobody ever saw the warning because
Apple totally removed it from the compiler they ship, and the gnustep-make
package has to automatically add -Wno-import to prevent a user rebellion
(they *do* want to use #import, if we don't let them, they start
complaining that Apple's compiler supports it, that it's so much better
than #include, and that they want to use it).



More information about the Gcc-patches mailing list